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.

MSP430FR2155: Timer CCR0 interrupt fail

Part Number: MSP430FR2155

Tool/software:

Hi experts,

My customer is testing timer_b_ex1_continousModeCCR0 on MSP430FR2155

He found that if he set the period of timer CCR0 from TB0 to several microseconds, There will be no CCR0 interrupt 

If he set the period of timer CCR0 to millisecond, the CCR0 interrupt is normal.

Any suggestions for this issue?

Thanks,

Leo

  • How do you tell that the CCR0 interrupt never triggers? (Breakpoint in the ISR? LED?)

    If you set COMPARE_VALUE to something less than (maybe something like) 100, I would expect a CCR0 interrupt roughly every 65ms, since by the time the ISR updates the CCR0 value the counter has already counted past it, so it has to cycle before reaching the (new) compare value.

  • Is the interrupt handler taking more time than the timer period?

  • It seems almost certain with a timer period of microseconds. I can't think of any good reason to schedule a timer interrupt at that rate.

  • Hi Bruce,

    The timer interrupt trigger interval is 50 microseconds (COMPARE_VALUE is 50). My client add the IO toggle in the ISR. And he cannot capture the toggle.

    Thanks

    Leo

  • I don't see this behavior on an FR2355 (Launchpad). I imported the Example and changed (only) COMPARE_VALUE to 50, and I see a span of roughly 62ms.

    Probing P1.0:

    I was able to get a short span (~120us) with COMPARE_VALUE=125, which provides some sense of how long the ISR takes to run.

    I was able to use COMPARE_VALUE=25 by replacing the (entire) ISR with:

        TB0CCR0 += COMPARE_VALUE;
        P1OUT ^= BIT0;
    

    I'm not sure what we're doing differently.

    [Edit: Minor clarification.]

  • Hi Bruce,

    Thank you for your confirm.

    My customer report he meet this issue by using API. Could you please check it?

    Thanks,

    Leo

  • This change would have to be matched with one in main():

      GPIO_setAsOutputPin(GPIO_PORT_P6, GPIO_PIN1);

    When I made both changes, I saw the same result with COMPARE_VALUE=50 (~62ms) as with P1.0 above.

    Adjusting COMPARE_VALUE wouldn't (in itself) enable/disable the P6.1 output. Are there other changes to the base Example?

  • Hi bruce,

    Could you please double check the time is 62ms or 62us?

    The client want to sent the period as 50us.

    Thanks,

    Leo

  • I don't have my equipment here, but the scope trace above indicates 62ms (not 62us) [*]. My other experiments indicate that -- with the Example code -- you won't do better than about 120us (COMPARE_VALUE=125) [*] since that's roughly how long the ISR takes. They also suggest a method (different ISR coding) which can reach about 25us [*].

    I didn't encounter any case where the ISR was never called.

    More generally: What is the goal here? This Example illustrates an interesting, but somewhat unusual case: generating a square wave on TBx.0, assuming that your design requires using Continuous Mode. If you can use Up Mode + the TB0.1 pin instead, that can be used to generate variable-duty PWM in hardware. Alternatively, if all you want is a 50% duty cycle, you can use OUTMOD=4 with TB0.0.

    [*] It measures 62ms rather than 65ms (presumably) since the system clock is running slightly fast (not tuned). These all assume that nothing else is going on in your system, which probably won't be the case in a real application.

  • Hi Bruce,

    My customer using this code

        TB0CCR0 += COMPARE_VALUE;
        P1OUT ^= BIT0;

    The minimum period he can get is 900us.

    More generally: What is the goal here?

    My customer wants to generate a series interrupt with the period of 50us. So he try to use the timer to generate a series interrupt with the period of 50us

    Thanks,

    Leo 

  • Can you post the code you're actually using? I suspect there's some relevant code outside what you've posted.

    More generally: It's not easy to do something useful in a 50us periodic ISR, particularly if you want your system to do anything else. You should plan on speeding up MCLK quite a bit.

**Attention** This is a public forum