AnsweredAssumed Answered

Button interrupt when pressed not when released

Question asked by WanneBe on Jan 4, 2017
Latest reply on Jan 13, 2017 by WanneBe

Hi,

I am trying to implement a Software to send Morse code on ADSP21489 EZKit Lite.

So far the DSP is able to make a signal when releaseing the button SW8 after I pushed it. But I want the DSP to make a Signal when pushing the button and stop making a signal when releaseing it. Does anyone know what to change?

 

void Init_PushButtons(void)
{
/* register the interrupt handlers */
adi_int_InstallHandler(ADI_CID_IRQ1I, (ADI_INT_HANDLER_PTR)short_sw8_button, NULL, true);
adi_int_InstallHandler(ADI_CID_IRQ2I, (ADI_INT_HANDLER_PTR)long_sw9_button, NULL, true);
/* pin assignments in SRU_PIN3 (Group D) */

SRU(LOW,DAI_PB19_I); /* assign pin buffer 19 low so it is an input */
SRU(LOW,DAI_PB20_I); /* assign pin buffer 20 low so it is an input */

/* route MISCA signals in SRU_EXT_MISCA (Group E) */

SRU(DAI_PB19_O,MISCA1_I); /* route so that DAI pin buffer 19 connects to MISCA1 */
SRU(DAI_PB20_O,MISCA2_I); /* route so that DAI pin buffer 20 connects to MISCA2 */

/* pin buffer disable in SRU_PINEN0 (Group F) */

SRU(LOW,PBEN19_I); /* assign pin 19 low so it is an input */
SRU(LOW,PBEN20_I); /* assign pin 20 low so it is an input */

/* unmask individual interrupts */
(*pDAI_IRPTL_PRI) = (SRU_EXTMISCA1_INT | SRU_EXTMISCA2_INT);

/* make sure interrupts latch on the rising edge */
(*pDAI_IRPTL_RE) = (SRU_EXTMISCA1_INT | SRU_EXTMISCA2_INT);
// (*pDAI_IRPTL_FE) = (SRU_EXTMISCA1_INT | SRU_EXTMISCA2_INT);

/* clear MSEN bit for this test */
(*pSYSCTL) &= ~(MSEN);

/* setup the IRQ pins to use the pushbuttons */
(*pSYSCTL) |= (IRQ1EN | IRQ2EN);

sysreg_bit_set(sysreg_MODE2, (IRQ1E | IRQ2E) );
sysreg_bit_clr(sysreg_IRPTL, (IRQ1I | IRQ2I) );

/* enable IRQ interrupts and make DAI interrupts high priority */
// sysreg_bit_set(sysreg_IMASK, (IRQ1I | IRQ2I | DAIHI) );

sysreg_bit_set(sysreg_MODE1, IRPTEN ); /* enable global interrupts */
SW8 = 0;
SW9 = 0;
}

 

static void short_sw8_button(int int_id, void* arg) {
int i;
SW8 = 1;
SW9 = 0;
}

static void long_sw9_button(int int_id, void* arg) {
int i;
SW9 = 1;
SW8 = 0;
}

 

 

void CW_modulation(float *output){
if(SW8){
sinGenerator(output, 0, 2, 256);
}else{

   for(int i=0; i<256; i++)
output[i] = 0;
}
}

 

float sinGenerator(float *output, float phase, float freq, int samples) {
int i;
for (i = 0; i < (samples); i++) {
output[i] = 0.9*sin((freq*2*3.14159265358979323846*i/samples));
}
return phase;
}

Attachments

Outcomes