Part Number:MSP430F5438A
Tool/software: Code Composer Studio
I have a task where I need to send sinusoidal PWM to LE diode. Frequency of such sine is changed via buttons and it goes from 1 Hz to 16 Hz.
MSP430 Timers are pretty sophisticated, and using appropriate output mode (reset/set = OUTMODE7) , they can easily generate PWM output, and send it to selected periphery, which is in my case Port4, pin 3, where is LE diode. Thus I am using compare register TB0CCR3, for resetting the impulse, and TB0CCR0 register for setting the impulse of PWM, all according to SLAU401E.
Problem is that sometimes when I change frequency to an even number(it is never an odd number), TB0CCR3 register seems to get stuck at value 0x0000, and won't change, thus making output to be zero, or in other words, LE diode does not emit light. Also, there is no regularity when this happens, only thing I can say, it does not happen with odd frequencies, just with even ones, and that happens sometimes with no regularity.
Interrupts were written in assembly, and main program was written in C.
Here are the codes:
(Please visit the site to view this file)(Please visit the site to view this file)