dsPIC 33fj16gs402 PWM call component Macro

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
garciacal
Posts: 3
Joined: Sun Mar 07, 2010 6:21 pm
Has thanked: 2 times

dsPIC 33fj16gs402 PWM call component Macro

Post by garciacal »

Hello All,

I didn't see a specific forum for dsPICs so I posted here, my apologies if it is out of place.

I have a 33fj16gs402 and the most recent version of dsPIC. I would like to setup a pwm signal at 10kHz using the built in pwm modules of the device. This is just to get familiar with the device and flowcode dsPIC.
I would like to use the internal oscillator.

I feel like there is a need to provide additional constructs via the code blocks to actually get it to work.

I have tried the call component macro to set the duty cycle and to enable it but no output on what I believe is pwm1. It does work in flowcode simulation.
I have an led blinking at .5hz so that I know that the device is running, but as stated I have no pwm signal.

The forum is very large and trying to walk through it all looking for previous questions on similar topics is rather arduous.

So my questions are does anyone have a related example that they could share to get me up and running? An example related to my unit with any pwm signal at any frequency and duty cycle would be helpful.
and/or
Does anyone have pointers to some c code for a code block to setup a test.

Thanks for any help,
and
Regards,

Reuben Garcia

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times

Re: dsPIC 33fj16gs402 PWM call component Macro

Post by dazz »

HI
Can you post your flowchart that way it can be adjusted to work, also can you sign up to the V% forums ,the link is in my sig

Regards
DAzz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

garciacal
Posts: 3
Joined: Sun Mar 07, 2010 6:21 pm
Has thanked: 2 times

Re: dsPIC 33fj16gs402 PWM call component Macro

Post by garciacal »

Thanks. Here is my test code. I tried to run the PWM module via a block of c code that is verbatim from the dsPIC33F Family Reference Manual and the rest is just a simple LED heart beat.

Again thanks for any help,

Reuben
Attachments
test.fcf_pic16
(8.5 KiB) Downloaded 203 times

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times

Re: dsPIC 33fj16gs402 PWM call component Macro

Post by dazz »

Hi Reuben
Have a look at the attached flowchart its heavilly commented to do what you want but using flowcode components instead of code blocks (sorry if i've over simplified it)
when you send it to your device don't forget to select build menu project options configure chip and set your options in there also disable the watchdog
I've also moved this topic to the V5 forums
Regards
Dazz
Attachments
test with comments.fcf_pic16
(11.5 KiB) Downloaded 193 times
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

garciacal
Posts: 3
Joined: Sun Mar 07, 2010 6:21 pm
Has thanked: 2 times

Re: dsPIC 33fj16gs402 PWM call component Macro

Post by garciacal »

dazz,

Thanks. It still didn't work. I tried a variation of that in the beginning. I have it working now with c code blocks. Earlier I assigned the digital out to the wrong pin. The problem with the PWM macros (not really a problem just too much to ask) is in flowcode. The macro blocks work fine for the regular pics, but the dspic need to have the PWM module initialized and don't see where that is being done in the 16bit_pwm.c. Also the dsPICs have to use the auxillary clock, which also needs to be initialized and that aclk needs to be running at 120 Mhz for ADC or PWM to work which just compounds how much flowcode would have to try and code across thousands of devices. I have attached a revised flowchart with my blocks in place. This is for a basic PWM and once configured a single c code command will enable or disable.

Now that I understand, I will update my copy of 16bit_pwm.c to handle the initialization routine and auxiliary clock spin up. This should let the component macro work with the dspic. I think an #ifdef could be added to separate out what is need across device classes, but I am not sure on that. I can post that modified 16bit_pwm.c back out when I finish if there is any interest.

Thanks again. I sincerely appreciate how quickly you responded when I first posted.

Regards,

Reuben
Attachments
Basic_PWM.fcf_pic16
(8.5 KiB) Downloaded 218 times

Post Reply