MSP430F5234: How to choose correct timer: Timer_A

Part Number: MSP430F5234

Hello,

I'm trying to use MSP430 Reference Code that was written for TI's Power over Ethernet ICs to print voltage/current logs of my test setup, I need to do this every 5-10 miliseconds.

The current timer being used in the main.c file is TIMER0_A1 and the lowest time interval I can get my print logs to be is ~50ms. I am doing this by reducing the counter in the code. Any ideas of which timer I can use to further reduce the counter so that I can increase my print log speed? 

image.png

  • How are you printing exactly? If you're logging over a UART, how fast does that run?

    At 9600bps (about 1 byte/msec) you can log 50 bytes in 50ms.

    You might try speeding up the UART, or shortening your messages.

    Where did you find the Reference code? [If I can find it, I'll see if I see anything.]

    [Edit: Fixed goof (sec->msec)]

  • This line of code:

    Implies the timer interrupt happens every 10/200 or 50ms. If you want something faster, you will have to change the timer configuration.

  • I am printing over UART at a baud rate of 9600. I have tried shortening my messages by commenting out what I don't need (which was most of the message), but that hasn't helped much. Here is the link to download the ref. code: SLVC771 Code example or demo | TI.com

    How do I change the timer configuration? Is that related to the timer vector or the value of counter?

  • It's not quite clear what your goal is here. If you want the debug output more often, just decrease the "counter" limit; setting it =100 will set PrintPower=1 every 5 seconds. 

    But to answer your question:

    In sys_init.c:Setup_Timer() TA0 is set to tick at SMCLK/8 (=1MHz evidently) in Up mode (MC=1). TA0CCR0 is set to 50000 for 50ms. If you want it to cycle (incrementing counter) faster you can set TA0CCR0 to a lower value, e.g. =25000 will cycle at 25ms. If you do that but want to keep the debug log at 10sec, you'll need to increase the "counter" limit to (200*2).

  • Hi Bruce, 

    Yep, realized I needed to change that config earlier today. Thanks for the inputs, I was able to get it working. 

    Best,

    Anagha

**Attention** This is a public forum