SparkFun Forums 

Where electronics enthusiasts find answers.

Everything ARM and LPC
By lpc1769
#151467
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.
Code: Select all

#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);
}

By lpc1769
#151568
fll-freak wrote:Why/how did this get marked as solved without a single reply or an edit for the OP? It would be nice to leave an explanation for the next person that comes along with a similar question.
hi fll-freak,

My apology, it was click solved unoticed. In fact, problem haven't solved yet. Thanks for pointing it out.
By Tanner
#165711
Ok, I hope for your sake you've gotten this to work by now. In case you haven't and for the sake of the next person that sees this page:

You have to power the RIT subsystem in the PCONP register. If you include:

PCONP |= (1<<16);

You should be able to use the RIT subsystem. Good luck!