Page 1 of 1

PWM-reconfigure not working on target

Posted: Thu Aug 29, 2013 7:27 pm
by Nigel_K
To realize a feasibility study by rapid prototyping, I wanted to create a selection-menu to switch between two different PWM-frequencies before the original application starts working. So it is a reconfiguration of the PWM on-chip module while the target is running (initializing). Concerning the program itself with simulated PWM-graphs everything works fine. But on the running target I figured out (by the use of an oscilloscope) that the PWM-frequency doesn't get changed. It stays always the same like the one that is set up on the property-menu of the PWM-part on the panel...
The component macro for PWM-parts owns a function that's called "ChangePeriod" that I'm using for reconfiguring.
Currently I'm using an Explorer 16 board (revision 5) for prototyping with a PIC24FJ128GA010 microcontroller – just for information. See the attached example and try it out on a running target...
Could you please help to solve this issue?! I'd be glad to get a statement soon. :)

Re: PWM-reconfigure not working on target

Posted: Thu Aug 29, 2013 9:22 pm
by kersing
In your code you set the new period before calling enable on the channels. The enable call sets the PWM to the values specified in the component properties effectively overwriting your new values. (The enable macro effectively calls SetPeriod with the values from the properties)
Change the order of the calls and you should be OK.

Re: PWM-reconfigure not working on target

Posted: Sat Aug 31, 2013 3:25 pm
by Nigel_K
Ahhhh ok - I didn't know about that behaviour. For my "logical" understanding it should normally be <<configure>> before <<enable>>. :o
I switched the order as recommended and it works as you said! - Thanks for the quick answer and your explanations concerning the "background". :)