• AVR Freaks

Hot!DSPIC33EP32MC202 - PWM Pins

Author
delmat
New Member
  • Total Posts : 14
  • Reward points : 0
  • Joined: 2018/08/01 09:53:05
  • Location: 0
  • Status: offline
2018/10/02 12:21:58 (permalink)
0

DSPIC33EP32MC202 - PWM Pins

Dear All,
 
for a new project I'd like to use the DSPIC33EP32MC202. In the datasheet I see that there are three couples of independent High Speed PWM.
In this board I need to drive independently 4 N-mosfet. I don't need a particular High speed PWM, a resolution of some dozens of usec could be ok.
 
Is it impossible to realize this with this microcontroller?
If it's impossible, which microcontroller do you recommend?
 
Thank you in advance,
 
Mattia
#1

15 Replies Related Threads

    MBedder
    Circuit breaker
    • Total Posts : 6755
    • Reward points : 0
    • Joined: 2008/05/30 11:24:01
    • Location: Zelenograd, Russia
    • Status: offline
    Re: DSPIC33EP32MC202 - PWM Pins 2018/10/02 12:42:15 (permalink)
    0
    It is possible for sure. But to implement this you have to blink a single LED first. Do it and come back when done.
    #2
    delmat
    New Member
    • Total Posts : 14
    • Reward points : 0
    • Joined: 2018/08/01 09:53:05
    • Location: 0
    • Status: offline
    Re: DSPIC33EP32MC202 - PWM Pins 2018/10/02 12:48:49 (permalink)
    0
    Dear MBedder,
     
    do you mean that I could manage PWM using timers and GPIO?
    #3
    KTrenholm
    Super Member
    • Total Posts : 708
    • Reward points : 0
    • Joined: 2012/08/08 14:04:23
    • Location: Connecticut, USA
    • Status: online
    Re: DSPIC33EP32MC202 - PWM Pins 2018/10/02 13:08:23 (permalink)
    4 (1)
    You need to drive 4 PWMs but it looks like that chip only has 3 PWM generators.    One of them will need to share a module with another.  You could maybe work something out but you'd be short one PWM if you want them all to be independent of one another.
     
    If you want 4 independently controlled PWM outputs you will need to look for a PIC that has 4 PWM Modules.
     
    Something like the dsPIC33FJ16GS402/404 has 4 fully independent PWM modules.
     
    [EDIT]
    I may be wrong on this, from pg197 of the datasheet:
    "Individual time base and duty cycle for each of the eight PWM outputs"
     
    but then on pg225:
    • Three PWM generators
    • Two PWM outputs per PWM generator
    • Individual period and duty cycle for each PWM pair
     
     It looks like you can do what you're looking to do with "True Independant PWM Output Mode" described in Section 14.6.4 of the Family Reference Manual (http://ww1.microchip.com/...DeviceDoc/70645C.pdf).
    post edited by KTrenholm - 2018/10/02 13:38:45
    #4
    T Yorky
    Super (Thick) Member
    • Total Posts : 519
    • Reward points : 0
    • Joined: 2012/08/28 02:07:35
    • Location: UK
    • Status: offline
    Re: DSPIC33EP32MC202 - PWM Pins 2018/10/03 07:14:20 (permalink)
    4.5 (2)
    Use output compare modules in PWM mode?
     
    T Yorky
    #5
    KTrenholm
    Super Member
    • Total Posts : 708
    • Reward points : 0
    • Joined: 2012/08/08 14:04:23
    • Location: Connecticut, USA
    • Status: online
    Re: DSPIC33EP32MC202 - PWM Pins 2018/10/03 07:22:12 (permalink)
    5 (1)
    T Yorky
    Use output compare modules in PWM mode?
     
    T Yorky




    Oh duh, you're super right.
    OP, that chip has 4 Output Compare modules.  You can use them in PWM mode instead of (or in combination with) the PWM Generators.
    #6
    delmat
    New Member
    • Total Posts : 14
    • Reward points : 0
    • Joined: 2018/08/01 09:53:05
    • Location: 0
    • Status: offline
    Re: DSPIC33EP32MC202 - PWM Pins 2018/10/03 23:39:13 (permalink)
    0
    Thank you very much for your support.
    Since I'm a newbie of embedded programming, I don't know how to use Output Compare Modules in PWM mode sad: sad.
     
    Do you know some examples to show me? 
     
     
    Best Regards,
     
    Mattia
    #7
    qhb
    Superb Member
    • Total Posts : 9998
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: DSPIC33EP32MC202 - PWM Pins 2018/10/03 23:44:56 (permalink)
    0
    delmat
    Since I'm a newbie of embedded programming, I don't know how to use Output Compare Modules in PWM mode

    Have you read that part of the datasheet yet?

    Nearly there...
    #8
    delmat
    New Member
    • Total Posts : 14
    • Reward points : 0
    • Joined: 2018/08/01 09:53:05
    • Location: 0
    • Status: offline
    Re: DSPIC33EP32MC202 - PWM Pins 2018/10/04 00:23:39 (permalink)
    0
    Dear qhb,
     
    I've read the datasheet and part of the reference manual and I understood how it work. With 16 bit register I can obtain an high precision PWM. I'd like to have some examples in order to start with someting already working that I can modify.
     
    Another thing that I don't understand: every GPIO pin can be used for PWM obtained with Output compare modules?
     
    Thank you in advance,
     
    Mattia
    #9
    qhb
    Superb Member
    • Total Posts : 9998
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: DSPIC33EP32MC202 - PWM Pins 2018/10/04 00:42:00 (permalink)
    5 (1)
    delmat
    I've read the datasheet and part of the reference manual and I understood how it work. With 16 bit register I can obtain an high precision PWM. I'd like to have some examples in order to start with someting already working that I can modify.

    That only works if someone comes along who has already done what you want, and shares their code.
    I haven't, so I can't help you there.
    Personally, I'd just try loading up the registers with something that looks reasonable, and use a scope to see what sort of waveform comes out of the chip.
     

    Another thing that I don't understand: every GPIO pin can be used for PWM obtained with Output compare modules?

    Almost every pin.
    The OCx outputs can be connected with PPS, so any pin that can be used as a PPS output can be used.
    (i.e. all the pins labelled RP## in  the pin diagram, but not ones labelled RPI##, as they are input only.)
     
     

    Nearly there...
    #10
    delmat
    New Member
    • Total Posts : 14
    • Reward points : 0
    • Joined: 2018/08/01 09:53:05
    • Location: 0
    • Status: offline
    Re: DSPIC33EP32MC202 - PWM Pins 2018/10/04 02:32:29 (permalink)
    0
    Thank you very much. For my curiosity, where did you get the information that all RP## pins are good?
    #11
    qhb
    Superb Member
    • Total Posts : 9998
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: DSPIC33EP32MC202 - PWM Pins 2018/10/04 02:50:33 (permalink)
    5 (1)
    From the PPS chapter of the datasheet.
    Specifically "11.4.4.3 Mapping Limitations"
     

    Nearly there...
    #12
    JPortici
    Super Member
    • Total Posts : 685
    • Reward points : 0
    • Joined: 2012/11/17 06:27:45
    • Location: Grappaland
    • Status: offline
    Re: DSPIC33EP32MC202 - PWM Pins 2018/10/04 02:59:48 (permalink)
    0
    KTrenholm
     It looks like you can do what you're looking to do with "True Independant PWM Output Mode" described in Section 14.6.4 of the Family Reference Manual



    Correct.
    Anyway, in this chip the difference between OC and HSPWM in terms of speed is that OC will run at most from FP, the HSPWM from FOSC, thus the HSPWM will run at double speed.
     
    @delmat please read AT least the datasheet before asking any more questions. it shouldn't take you more than half an hour to do it.
    post edited by JPortici - 2018/10/04 03:00:56
    #13
    delmat
    New Member
    • Total Posts : 14
    • Reward points : 0
    • Joined: 2018/08/01 09:53:05
    • Location: 0
    • Status: offline
    Re: DSPIC33EP32MC202 - PWM Pins 2018/10/04 04:37:38 (permalink)
    0
    Thank you.
     
    In fact I read the datasheet. It's not a matter of laziness, it's because I'm new to these arguments and sometimes the reading is not enough to clarify the concepts.
     
    Best Regards
    #14
    JPortici
    Super Member
    • Total Posts : 685
    • Reward points : 0
    • Joined: 2012/11/17 06:27:45
    • Location: Grappaland
    • Status: offline
    Re: DSPIC33EP32MC202 - PWM Pins 2018/10/04 05:27:56 (permalink)
    5 (1)
    I understand. Sorry, but it didn't appear to be the case with the way you posed the questions.
     
    Setting up the hardware in this MCU is rather easy. Most of the digital functions don't have dedicated pins, as in the OC peripheral, so you have to assign the function to the PIN. (by the way, in case you need it, you can assign the same peripheral to multiple functions. For example i was testing if i could make a useful cheap-o charge pump or boost converter for a negative rail, in order to switch the PNP/FET harder/faster i assigned the OC output to two pins pins to increase the current available)
     
    You first have to identify which pins can be used. in dsPICs they are called RPx. for example, RB10 is also RP42.
    each peripheral has a code (which you can find in the PPS chapter of the datasheet), just write that code in the RPxR field of the RPORy register
    (pro tip, in XC16 you can use for example _RP42R = xxx instead. _RP42R is a macro that expands to the appropriate bitfield)
     
    after that it's a matter of setting up the peripheral, which should be rather easy. in the Output Compare reference manual (which you find in the pic product page under the documents section) there is a detailed description of the peripheral, registers, modes, prodivind code examples (in C, using XC16)
    #15
    delmat
    New Member
    • Total Posts : 14
    • Reward points : 0
    • Joined: 2018/08/01 09:53:05
    • Location: 0
    • Status: offline
    Re: DSPIC33EP32MC202 - PWM Pins 2018/10/04 05:43:17 (permalink)
    0
    Thank you,
     
    I'll work on it!!! Thanks to all the user that answered me! Your answer are very helpful!
    #16
    Jump to:
    © 2019 APG vNext Commercial Version 4.5