Page 1 of 1

dsPIC 33fj16gs402 PWM call component Macro

Posted: Tue May 07, 2013 6:43 pm
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

Re: dsPIC 33fj16gs402 PWM call component Macro

Posted: Tue May 07, 2013 7:03 pm
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

Re: dsPIC 33fj16gs402 PWM call component Macro

Posted: Tue May 07, 2013 9:35 pm
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

Re: dsPIC 33fj16gs402 PWM call component Macro

Posted: Tue May 07, 2013 10:47 pm
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

Re: dsPIC 33fj16gs402 PWM call component Macro

Posted: Wed May 08, 2013 3:28 pm
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