Microcontrollers have on-board timers that are free running that can be used for various things. It is very useful for executing code that needs to be run at a constant interval.
- Configure and set up the timer and the interrupt.
- Program the microcontroller to handle the interrupt and execute code (toggle LED).
Timers can be really useful for updating something or feeding in data at a constant interval. This works better than having to constantly check something (polling) in the main code because it would use up too much resources.
I encountered a lot of issues while going through this lab. For one, I was using the wrong target microcontroller because I didn’t realize that the microcontroller that came on the board was completely different from what I thought. The development kit came with two microcontrollers that you can hotswap. This also meant that I was looking at the wrong data sheets when I initially started this lab. I also ran into the issue of not using the proper interrupt vector and clock but that was easily solved by trial and error.
&TA0CTL: Timer control register.
#TASSEL_X: Timer input clock select.
#MC_X: Timer counter mode select.
#ID_X: Timer clock divider select.
#TAIFG: Timer register overflow interrupt flag.