I tried to understand the frequency working of the logging but do not understand how it calculates the counter value for IRQ.
The T0MR0 = 58982400 / freq; should match the clock speed of 12 mHz at a frequency of 1Hz. It is 4,9 times bigger. I tested the frequency and it really works at 20Hz.
Does anyone know how it works?
This is the timer setup code:
void mode_2(void)
{
rprintf(“MODE 2\n\r”);
enableIRQ();
// Timer0 interrupt is an IRQ interrupt
VICIntSelect &= ~0x00000010;
// Enable Timer0 interrupt
VICIntEnable |= 0x00000010;
// Use slot 2 for UART0 interrupt
VICVectCntl2 = 0x24;
// Set the address of ISR for slot 1
VICVectAddr2 = (unsigned int)MODE2ISR;
T0TCR = 0x00000002; // Reset counter and prescaler
T0MCR = 0x00000003; // On match reset the counter and generate interrupt
T0MR0 = 58982400 / freq;
T0PR = 0x00000000; // Disable preset register
T0TCR = 0x00000001; // enable timer
stringSize = 512;
mode_action();
}