Hi all,
I am using LPC1769.
What i would like to achieve is that, every 40 ms, i would like to have auto interrupt and print out a message.
I have searched and found out that it can be achieved using Repetitive Interrupt Timer to generate interrupts at specified time intervals.
I have understood meanings of 4 registers associated with RI (such as ICOMPVAL, RIMASK, RICTRL, RICOUNTER).
Once i run my code, i encountered hard fault. Can kindly check for me where i went wrong. Thank you.
#include "stdio.h"
#include "LPC17xx.h"
// EINT3 Interrupt Handler
void RIT_IRQHandler(void)
{
printf("Repetitive interrupt every 40 ms\n");
// Clear RI Control register Interrupt
LPC_RIT->RICTRL |= 1<<0; //bit 0 = 1 => write 0 to value 1 will clear the interrupt flag
}
int main (void)
{
//RI compare value register -> Compare value to get 40 ms, cpu speed is 120 000 000
LPC_RIT->RICOMPVAL |= 0x493E00; //OR operation so that existing values will not be effected
//RI mask register -> RI masking to compare with counter
LPC_RIT->RIMASK |= 0x493E00;
//RI control register
LPC_RIT->RICTRL |= 1<<1; //bit 1 = 1 => The timer will be cleared to 0 whenever the counter value equals RICOMPVAL
LPC_RIT->RICTRL |= 1<<3; //bit 3 = 1 => Timer enable
// Enable RI TINT interrupt
NVIC_EnableIRQ(RIT_IRQn);
while(1);
}