Tool/software: Code Composer Studio
A question about the frequency of systick timer.
First, I use DCO to generate a 8.33M MCLK, and then configure the SYSTICK TIMER to generate an interrupt per 0.5S. LED after the run of the program to achieve the 0.5S flashing. The code reads as follows:
int main(void)
{
/* Halting the Watchdog */
MAP_WDT_A_holdTimer();
/* Configuring GPIO as an output */
MAP_GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);
//![Simple FPU Config]
/* Enabling FPU for DCO Frequency calculation */
MAP_FPU_enableModule();
MAP_CS_setDCOCenteredFrequency(8330000);
/* Configuring SysTick to trigger at 4165000 (MCLK is 8.33MHz so this will
* make it toggle every ~0.5s) */
MAP_SysTick_enableModule();
//MAP_SysTick_setPeriod(4165000);
MAP_SysTick_setPeriod(4165000);
MAP_Interrupt_enableSleepOnIsrExit();
MAP_SysTick_enableInterrupt();
/* Enabling MASTER interrupts */
MAP_Interrupt_enableMaster();
mclk = CS_getMCLK();
while (1)
{
MAP_PCM_gotoLPM0();
}
}
void SysTick_Handler(void)
{
MAP_GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0);
}
Then I clocked DCO as 48M, and in order for SYSTICK TIMER to produce a 0.5 break, I set SYSTICK TIMER's Period as half of MCLK: “SysTick_setPeriod (24000000);”
After the program is run, the LED blinks very quickly, and obviously the SYSTICK TIMER interrupt is not 0.5S.
I want to know how to solve this problem. Is my SYSTICK timer driving clock wrong?
The code reads as follows:
int main(void)
{
/* Halting the Watchdog */
MAP_WDT_A_holdTimer();
/* Configuring GPIO as an output */
MAP_GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);
//![Simple FPU Config]
/* Enabling FPU for DCO Frequency calculation */
MAP_FPU_enableModule();
MAP_PCM_setCoreVoltageLevel(PCM_VCORE1);
MAP_FlashCtl_setWaitState(FLASH_BANK0, 2);
MAP_FlashCtl_setWaitState(FLASH_BANK1, 2);
/* Setting the DCO Frequency to a non-standard 48MHz */
/* Initializes Clock System */
MAP_CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_48);
MAP_CS_initClockSignal(CS_MCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1 );
MAP_CS_initClockSignal(CS_HSMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1 );
MAP_CS_initClockSignal(CS_SMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1 );
MAP_CS_initClockSignal(CS_ACLK, CS_REFOCLK_SELECT, CS_CLOCK_DIVIDER_1);
//![Simple FPU Config]
/* Configuring SysTick to trigger at 24000000 (MCLK is 48MHz so this will
* make it toggle every ~0.5s) */
MAP_SysTick_enableModule();
MAP_SysTick_setPeriod(24000000);
MAP_Interrupt_enableSleepOnIsrExit();
MAP_SysTick_enableInterrupt();
/* Enabling MASTER interrupts */
MAP_Interrupt_enableMaster();
mclk = CS_getMCLK();
while (1)
{
MAP_PCM_gotoLPM0();
}
}
void SysTick_Handler(void)
{
MAP_GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0);
}