Hello, everyone.
I'm having a problem while trying to configure the Systick Interrupt.
Currently my program generates an interrupt every 1 msec. All I do inside the interrupt routine is increasing a counter.
I'm also using the System ADC to register data from 3 different channels. The ADC is triggered every 1 msec, using a Timer0 interrupt.
The Systick counter is used as a "Time-Stamp" for the registered variables.
The problem is, now I'm trying to modify the code to sample at 2Khz, (i.e every 0,5 msec). In order to keep up with this change, I need to modify the Systick as well, to be triggered every 0,5 msec.
This is the code for the Timers and Systick definitions. The sampling time is configured in the variable "SAMPLETIME".
void InitializeTimers(void) { // Enable Timer peripherics. ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); // Timer 0, to trigger ADC conversions // Enable Processor Interrupts. ROM_IntMasterEnable(); // Configure the periodic 32bits Timer ROM_TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC); ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, SAMPLETIME); //Triggered every 1msec // Enable Timeout Interruptions for TIMER0A ROM_IntEnable(INT_TIMER0A); ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); // Configure - Enable Systick ROM_SysTickPeriodSet(40000); // 1ms @ 40MHz ROM_SysTickIntEnable(); ContadormsegSystick=0; ROM_SysTickEnable(); // Starts ticking }
The System clock is set to 40Mhz
ROM_SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
When SAMPLETIME=40000, and ROM_SysTickPeriodSet(40000); ------ Everything works OK.
When SAMPLETIME=20000, and ROM_SysTickPeriodSet(20000); ------ All registered Systick's are 0. The system just doesn't work.
As far as I understand, Systick should work no matter the Clock Frequency. Is this OK?
Or am I perhaps having a problem in some other part of the code, which could be interfering?
(Just to mention, I'm also using the EEPROM, and UARTprintf commands, but I never change the system clock, or anything else. All I do is modify the SAMPLETIME value).
Thanks for taking the time to read this.
Regards,
Martín.