PWM-reconfigure not working on target

Moderator: Benj

Post Reply
Nigel_K
Flowcode v5 User
Posts: 8
Joined: Thu Aug 29, 2013 3:43 pm
Has thanked: 4 times

PWM-reconfigure not working on target

Post 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. :)
Attachments
PWM_reconfigure.fcf_pic16
(41.5 KiB) Downloaded 401 times

kersing
Valued Contributor
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

Post 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.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Nigel_K
Flowcode v5 User
Posts: 8
Joined: Thu Aug 29, 2013 3:43 pm
Has thanked: 4 times

Re: PWM-reconfigure not working on target

Post 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". :)

Post Reply