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.
PWM-reconfigure not working on target
Moderator: Benj
PWM-reconfigure not working on target
- Attachments
-
- PWM_reconfigure.fcf_pic16
- (41.5 KiB) Downloaded 401 times
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
Re: PWM-reconfigure not working on target
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.
Change the order of the calls and you should be OK.
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis
Re: PWM-reconfigure not working on target
Ahhhh ok - I didn't know about that behaviour. For my "logical" understanding it should normally be <<configure>> before <<enable>>.
I switched the order as recommended and it works as you said! - Thanks for the quick answer and your explanations concerning the "background".
I switched the order as recommended and it works as you said! - Thanks for the quick answer and your explanations concerning the "background".