Jump to content

Fixed Length Triggers


marioguzzi
 Share

Recommended Posts

Hi,

I'm planning to develop an application that reacts to note-on midi messages to trigger dout pins for a fixed time, using the Timer or Tick function seems the way to go but being not really a coder I'm a bit confused on the approach to use.

Any idea?

I tried searching the forum but it seems the search engine is not working

Link to comment
Share on other sites

Define an array which contains counter variables for each individual DOUT pin:


// in this example for up to 16 pins
#define NUM_DOUT_DELAY_CTR 16
unsigned char dout_delay_ctr[NUM_DOUT_DELAY_CTR];
[/code] initialize these counters in Init():
[code]
void Init(void) __wparam
{
unsigned char i;

for(i=0; i<NUM_DOUT_DELAY_CTR; ++i)
dout_delay_ctr[i] = 0;

// ...remaining init stuff...
Add following code to SR_Service_Finish():

void SR_Service_Finish(void) __wparam
{
unsigned char i;

for(i=0; i<NUM_DOUT_DELAY_CTR; ++i)
if( dout_delay_ctr[i] && --dout_delay_ctr[i] == 0 ) {
MIOS_DOUT_PinSet(i, 0);
}
}
[/code]

done!

Whenever you set a pin, set "dout_delay_ctr[pin]" to a value between 1..255

This value defines the delay in mS after which the DOUT pin will be cleared again.

Best Regards, Thorsten.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...