This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP432 launchpad(red board) clock

Hi,

I wrote the following code to generate an interrupt using SysTick.The interrupt should arrive at 10ms considering the launchpad clock running at 3Mhz by default.I have not configured the launchpad clock.I am using the default setting on the launchpad board.I get the interrupt at 3ms.Why is the timing going awry.

#include "msp.h"
volatile uint32_t msTicks = 0;
void Sleep(void);

int main(void){
__disable_irq();
SysTick->LOAD = 3333333-1;
SysTick->CTRL = 7;
NVIC_SetPriority(SysTick_IRQn,2);

__enable_irq();
while(1){
Sleep();
}

}

void SysTick_Handler(void){
msTicks++;

}

void Sleep(void){
__wfi();

}

  • Govind:
    You should take a look at
    processors.wiki.ti.com/.../Getting_Started_with_the_MSP430_LaunchPad_Workshop

    It will answer a lot of questions regarding MSP430, including this one, and is very good material.
  • The SysTick is a counter that loads the value from the STRVR (SysTick reload value register) into the counter register and decrements that value with every MCLK cycle (in your case MCLK = 3MHz). Once the register reaches zero, an the SysTick interrupt is issued and the counter register reloads the value from STRVR.
    Now, you are loading it with (3333333-1) = 3,333,332 which is more than 3 * 10^6 (your clock frequency), so in theory the SysTick Interrupt should be triggered less frequently than every second.
    Or are you asking about the _first_ SysTick Interrupt? This is given by the reset value of the STCVR register (SysTick->VAL), which is undefined, you have to set it yourself to SysTick->LOAD, to have the correct period from the start.

    Hope that helps a bit,
    Dan
  • Dear Todd,
    First accept my apologies since there was an error in the value.It should be SysTick->LOAD = 33333-1;
    I have seen all that material on the wiki.
    My question is this:
    The clock supplied is 3Mhz.It means that every clock cycle is 0.333usec.
    So to have ,say 10ms of time we need to have 33,333 counts.
    But with this count the interrupt arrives at 3.3ms.Why is this happening
  • Hello,
    Do you see a similar issue with the code example? dev.ti.com/.../

    Thank you,
    Chris
  • Hi,

    I am using 3Mhz default clock.But in the Keil IDE the TI XDSdebugger has the trace section with a clock setting running at 10 Mhz.
    Is this the culprit.I have to set this to 3Mhz.

    Pls excuse me for asking such a basic question.Since all this while I was using the simulator.My board arrived two days ago.

    Thanks in advance
  • I think that is it. Please let me know if changing the clock setting in the debugger does not help or explains the behavior.

    Regards,
    Chris
  • Hi,

    Changing the clock in the trace of the debugger solved the problem

    Thanks

    Govind G.

**Attention** This is a public forum