This webpage provides information about the TIMERA2 hardware library created for the MSP430F5529LP Development Board.
These files are optional. They only need to be included if the TIMERA2 functionality is desired. If they are not included, the TIMERA2 module will remain disabled.
When included, the MSP430F5529LP_TIMERA2.h/c files configure the TIMERA2 timer as an up-counter timer that generates an interrupt once per millisecond. This interrupt is not visible at the application level, but is used to increment a 16-bit and 32-bit tick counter, which are then used to provide various delay and timeout capabilities. The maximum timeout for the 16-bit functions is 65.535 seconds. The maximum timeout for the 32-bit functions is 49.7 days.
CAUTION: The MSP430 is a 16-bit processor, and 32-bit operations are not atomic! This means that an interrupt can occur in the middle of a 32-bit operation, and the results may be unpredictable. This is particularly dangerous for 32-bit values being updated by an ISR, such as the 32-bit tick counter in this library. The 32-bit functions provided in this library disable interrupts during 32-bit operations to maintain integrity. Although functions like millis(), GetTick32(), and Elapse32() are provided It is highly recommended that the Expired32() function provided be used to determine whether a 32-bit timer has expired, as opposed to performing these operations and comparisons in the application code.
The following example code is provided to demonstrate the functionality of this library. All examples are presented as main.c files, which are available on GitHub. In order to build the example projects, follow the instructions here for how to create and configure a new project.
Example | Summary Description |
---|---|
Using the TimerA2 blocking delay |
This example uses the TIMERA2 hardware library to generate a sequence of blocking delays that blink the LEDs. Blocking delays are very simple to use and understand, and can be useful for creating very simple programs quickly. They have a significant drawback however that they prevent the processor from performing other tasks while it waits for the delay to complete. Requires: Only the MSP430F529LP development board. |
Using the TimerA2 non-blocking delay |
This example uses the TIMERA2 hardware library to generate a state machine using non-blocking delays that blink the LEDs. The use of the non-blocking delays adds a little complexity to the program flow, however it is a very powerful foundation for creating large applications that can process many tasks simultaneously. Requires: Only the MSP430F529LP development board. |