AnsweredAssumed Answered

Interrupt and variable

Question asked by luca di nunzio on Jan 15, 2017
Latest reply on Jan 15, 2017 by Con Verse

Hi to all, i am new with lpcxpresso and i have a simple question

 

i would like change the value of a variable during an interrupt but the interrupt function is void, for this reason i try to use extern volatile variable but it seems not work

 

 

this is the code

 

extern volatile uint64_t counter_1=0;

 

 


void RIT_IRQHandler(void)
{

 

 

 


/* Clear interrupt */
Chip_RIT_ClearIntStatus(LPC_RITIMER);

counter_1=counter_1+1;
printf(" counter_1 vale %d \n",counter_1);

 

Board_LED_Toggle(1);

 

}

 


/**
* @brief Main entry point
* @return Nothing
*/
int main(void)
{

 

/* Generic Initialization */
SystemCoreClockUpdate();
Board_Init();

/* Initialize RITimer */
Chip_RIT_Init(LPC_RITIMER);

/* Configure RIT for a periodic interrupt tick rate */
Chip_RIT_SetTimerIntervalHz(LPC_RITIMER, TIME_INTERVAL);
Chip_RIT_Enable(LPC_RITIMER);


NVIC_EnableIRQ(RITIMER_IRQn);

/* LED is toggled in interrupt handler */
while (1) {
/* Sleep between interrupts */
__WFI();
}
}

 

 

i would like increment the variable counter_1 every time an interrupt occours but it seems not work

 

thx you

Outcomes