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.

MSP430G2553: Can I write to TA0R while TimerA0 is running?

Part Number: MSP430G2553


Hi,

Good Day. I have a customer who is working with MSP430G2553. I suggested several links to him for his query but he has another question about the link. Please see below the query of the customer and the links that I send to him. Thank you very much.

Do I need to stop the timer when writing to or reading from TA0R? When I restart the timer after changing the TA0R value, does the timer start from that value or does it start from zero? Do I need to clear the interrupt flags for the enabled interrupts every time I change any Timer register? Do I need to disable interrupts prior to changing any of the timer registers?

e2e.ti.com/.../msp430g2553-timer-a0-issue-in-msp430

e2e.ti.com/.../msp430g2553-timer-a-difference-between-taie-in-taxctl-and-ccie-in-ta0cctl0-register-in-mode-control-1-up-to-ta0ccr0

e2e.ti.com/.../2529317

e2e.ti.com/.../msp430g2553-msp430g2553-timer0_a0-and-timer0_a1-triggerering-at-the-same-time

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/867731/msp430g2553-timera-instead-of-delay-function?tisearch=e2e-sitesearch&keymatch=MSP430G2553%252520TA0R#

Best Regards,

Ray Vincent

  • The first is easy as a quick RTFM would turn up the note in 12.2.1 telling you to stop the timer before modifying its operation.

  • Hi David,

    Good Day. Please see below for another query from the customer. Thank you very much.

    I have a problem with current consumption. I am using the Base Energy Trace and I see pulses of current of 3mA. The pulses are 145us long and spaced 50us to 200us, one pulse followed by a group of four. My code sleeps most of the time and wakes up once every 1/2 sec with a very short ISR. What could be causing these pulses?

    Best Regards,

    Ray Vincent

  • It sounds like there is more than the one ISR.

  • When I restart the timer after changing the TA0R value, does the timer start from that value or does it start from zero? If you choose the up mode, yes. You can see the register value to double check in debug mode.

    Do I need to clear the interrupt flags for the enabled interrupts every time I change any Timer register?  You don't need to clear the interrupt flags, it will be cleared automatically, when it enters ISR.

    Do I need to disable interrupts prior to changing any of the timer registers?  It depends what you want to realize. If you don't want the ISR happens when you change the timer register. You can disable the interrupt. If you update the CC register, it will be updated when the counter count to 0.

    For the power consumption problem. I advise you to disable some software function to check what is the root cause.

  • Hi Eason,

    Good Day. Please see below the response of our customer to your suggestion. Thank you very much.

    "You don't need to clear the interrupt flags, it will be cleared automatically, when it enters ISR". What if I change the timer register outside the ISR?

    I could not get the "Timeline" feature in IAR IDE to report correct current. It reported 37mA correctly when my radio chip was transmitting (timeline showed 2.5ms of this), but after the Tx, timeline showed 27mA for 161ms. I measure the current with a clamp on current probe: 37mA for 3.9ms followed by 3mA for 1.4ms followed by sleep current. Also, timeline introduced pulses onto the VCC line. Sometimes, timeline did not show the 27mA, but it was inconsistent. Maybe the pulses affect the measurement. I stopped using timeline.

    I did get my code working. There is only one remaining problem: sleep current. The sleep current is 45uA. I only have three devices on the board (uC, radio, reg). All three are disabled in sleep. On timer exit, I use: __bis_SR_register_on_exit(LPM3_bits|GIE);

    Best Regards,

    Ray Vincent

  • 1. Which register you want to change? As you have get it work, is there any risk that make you to have some concern?

    2. Sorry. What's the problem that you remain? The average current is too high or the sleep current is too high?

    3. If you are talking about sleep current. I think you can test after you remove all the three devices one by one to check which one consume the most power.

  • __bis_SR_register_on_exit(LPM3_bits|GIE);

    I can't think of any context where this would do what you want to do. In main(), to go into LPM, use:

    > __bis_SR_register(LPM3_bits|GIE);        // Sleep (enabled) until interrupt 

    In the ISR, to take main out of LPM, use:

    > __bic_SR_register_on_exit(LPM3_bits);   // Wake up main

  • Hi Eason,

    Good Day. Please see below the response of our customer to your question. Thank you very much.

    1. The register I am changing is TA0R. Not much concern as it is working.

    2. The average current is fine. It is the sleep current which is too high (45uA).

    3. Difficult to remove the devices while board is operating. Also, not a fair test because the devices are all sleeping. It will not be clear which device is driving which. I would like clear guideline on what to do which each port pin of the TI micro when it is connected to another sleeping device. One of the micro port pins is an enable output to one of the devices. It needs to be low when the micro sleeps. Can I configure as a output and drive it low just before making micro sleep, or do I need to use a pulldown? Another micro port pin needs to be high when the micro sleeps. Can I configure as output and drive it high or do I need to use pullup? What should I do with the micro port pins which are input pins? When the devices which drive them are asleep, their outputs will be low. Is this sufficient or do I need to use pulldowns.

    Best Regards,

    Ray Vincent

  • 1. The lowest power setting for GPIO is to make it output low. Pulldown will not do much help.

    2. I advise you make a try for your different assumptions.

    3. As the sleep current is 45uA. I am sure MSP430 comes to LPM3. All the things you need to do on MSP430 side, is to check the GPIO setting. If you use internal crystal, it also will cause the current to be little high.

  • Hi Eason,

    Good Day. Please see below the response of our customer to your latest reply. Thank you very much.

    I use only 32KHz crystal. Please answer my questions: One of the micro port pins is an enable output to one of the devices. It needs to be low when the micro sleeps. Can I configure as a output and drive it low just before making micro sleep, or do I need to use a pulldown? Another micro port pin needs to be high when the micro sleeps. Can I configure as output and drive it high or do I need to use pullup? What should I do with the micro port pins which are input pins? When the devices which drive them are asleep, their outputs will be low. Is this sufficient or do I need to use pulldowns. I have more findings: I saw current bumps occurring at a 60Hz rate. A physical 1Mohm pulldown resistor placed on pin 10 of the micro eliminated them. The sleep current is now 1.8uA (what I expect). I tried doing this with software with no success (commands lines: P2DIR=0x73; P2OUT=0x01; P2REN&=~BIT2;). Why did the software pulldown on pin 10 not work?

    Best Regards,

    Ray Vincent

  • >P2DIR=0x73; P2OUT=0x01; P2REN&=~BIT2;

    This turns off the internal pulldown on P2.2 (pin 10). Try:

    > P2DIR=0x73; P2OUT=0x01; P2REN |= BIT2;

    Generally, your MCU's GPIO settings should be governed by the data sheet(s) for the device(s) at the other end. If the device's pin is "Input" you should drive (output) at the MCU pin and for a device "Output" the MCU should configure as input. Scan the device data sheet for notes about "internal pull{up/down}"s, which aren't always right there at the pin descriptions. Also, if there's any chance the device might be disconnected in your system, you might consider using a pull{up/down} at a level which won't set up a bus conflict if the device is connected. (You can also switch the MCU side from pullup to pulldown on the fly pretty easily.)

    Unsolicited: If you're using a 20-pin device, consider the second "NOTE" about P3REN below the "Device Pinout" on data sheet (SLAS735J) p.3.. It's my understanding that the 20-pin and 28-pin dies inside the chip are the same, and the extra pads are just unconnected and floating.

  • Hi Bruce,

    Good Day. Another question came from our customer. Please see below for your reference. Thank you very much.

    "How do I create and download "Release" code as opposed to "Debug" code using the IAR IDE?"

    Best Regards,

    Ray Vincent

  • I haven't used IAR in some years, but according to the IDE User Guide (UIDE430-10) p. 111, there's a drop-down menu at the top of the Workspace view. I found the UG here:

    https://wwwfiles.iar.com/msp430/webic/doc/EW430_IDEGuide.pdf

**Attention** This is a public forum