Hii
I'm working on the LCD display interfacing where in the datasheet of the LCD its mentioned that I have to give delays in microseconds, milliseconds and in nanoseconds. According to the sysctl.c driver, sysctldelay() is not accurate. That is why i tried to give delay using timer0 I'm attaching the code below. I was able to apply 10 millisecond delay now I want to create 160 microsecond delay and 400 nanoseconds delay so how can create macro and nanoseconds delay using timer0 can anyone please help me to do so?
void timer0A_delayMs(int ttime)
{
int i;
SYSCTL->RCGCTIMER |= 1; /* enable clock to Timer Block 0 */
TIMER0->CTL = 0; /* disable Timer before initialization */
TIMER0->CFG = 0x04; /* 16-bit option */
TIMER0->TAMR = 0x02; /* periodic mode and down-counter */
TIMER0->TAILR = 50000 - 1; /* (Using 50Mhz clock) Timer A interval load value register */
TIMER0->ICR = 0x1; /* clear the TimerA timeout flag*/
TIMER0->CTL |= 0x01; /* enable Timer A after initialization */
for(i = 0; i < ttime; i++)
{
while ((TIMER0->RIS & 0x1) == 0) ; /* wait for TimerA timeout flag */
TIMER0->ICR = 0x1; /* clear the TimerA timeout flag */
}
}
Regards
Omkar