• AVR Freaks

Hot!High-Speed PWM Odd Signal When Disabled

Author
bassbreaker
New Member
  • Total Posts : 3
  • Reward points : 0
  • Joined: 2019/06/12 13:50:05
  • Location: 0
  • Status: offline
2019/06/13 11:11:16 (permalink)
0

High-Speed PWM Odd Signal When Disabled

I am using the High-Speed PWM module on the dsPIC33EP64GS506. I am using PWM1H/L and PWM3H/L. When enabled and running everything works as expected. However, there are times that I want to disable the module, that is, I want all 4 PWM pins (1L,1H,3L,3H) to output 0V. I can achieve this for PWM1 by disabling the PWM module altogether (i.e. PTCONbits.PTEN = 0). But when I do this, the signal on the output of PWM3 is odd. PWM3H is a very noisy signal that sits at around 2.8V and PWM3L is a signal that sits at around 0.5V.
I currently do a work around to "disable" the PWM signals by writing 0 to PDC1 and PDC3, but this isn't the correct thing to do. Is there a better way to disable the PWM signals? I don't see that I am doing anything different in the software between PWM1 and PWM3.
It is worth noting that the PWM3 signals are currently open and not connected to anything and I still get the same issue. It is also worth noting that before I enable the PWM module (i.e. PTCONbits.PTEN = 1) PWM3H/L are at 0V. They only go to an uncertain state after asserting and then dis-asserting the PTEN bit.
 
My PWM initialization routine looks like this (where max_pwm_val is an int~=3000):
    PTCON2bits.PCLKDIV = 0;            //PWM time base prescaller 1:1

    PWMCON1bits.CAM = 1;            //Center align mode
    PWMCON1bits.ITB = 1;            //Independent Time base PHASEx/SPHASEx (needed for center)
    PWMCON1bits.MDCS = 0;            //PDCx/SDCx provide duty
    PWMCON1bits.DTC = 0;            //Positive Dead-Time
    
    PWMCON3bits.CAM = 1;
    PWMCON3bits.ITB = 1;
    PWMCON3bits.MDCS = 0;
    PWMCON3bits.DTC = 0;

    PWMKEY = 0x0;
    __builtin_write_PWMSFR(&IOCON1, 0xC000, &PWMKEY);
    __builtin_write_PWMSFR(&FCLCON1, 0x408, &PWMKEY);
    __builtin_write_PWMSFR(&IOCON2, 0x0000, &PWMKEY);           //Disable PWM2H/L
    __builtin_write_PWMSFR(&IOCON3, 0xC000, &PWMKEY);
    __builtin_write_PWMSFR(&FCLCON3, 0x408, &PWMKEY);
    __builtin_write_PWMSFR(&IOCON4, 0x0, &PWMKEY);              //Disable PWM4H/L
    __builtin_write_PWMSFR(&IOCON5, 0x0, &PWMKEY);              //Disable PWM5H/L
    
    PDC1 = max_pwm_val/2;
    PHASE1 = max_pwm_val;                    //Period for PWM1H, 300 kHz; 1592
    ALTDTR1 = 100;                    //Dead-Time is 10 ns
    
    PDC3 = max_pwm_val/2;
    PHASE3 = max_pwm_val;
    ALTDTR3 = 100;

 
It may also be worth noting that I am setting the TRIS register so that they are outputs.
TRISA = 0x0007;
TRISB = 0x27CB;
(PWM3H -> RB11, PWM3L -> RB12, PWM1H -> RA4, PWM1L -> RA3).
 
#1

4 Replies Related Threads

    bassbreaker
    New Member
    • Total Posts : 3
    • Reward points : 0
    • Joined: 2019/06/12 13:50:05
    • Location: 0
    • Status: offline
    Re: High-Speed PWM Odd Signal When Disabled 2019/06/18 07:01:39 (permalink)
    0
    So I guess no one has any ideas? Is disabling the PWM module the proper way to set the pins to 0V?
    #2
    Aussie Susan
    Super Member
    • Total Posts : 3618
    • Reward points : 0
    • Joined: 2008/08/18 22:20:40
    • Location: Melbourne, Australia
    • Status: offline
    Re: High-Speed PWM Odd Signal When Disabled 2019/06/18 20:26:18 (permalink)
    0
    Have you read Section 12 of the FRM (High Speed PWM Module)?
    I've not used this MCU or module in other MCUs but that section does look like it might be appropriate.
    Susan
    #3
    MBedder
    Circuit breaker
    • Total Posts : 6794
    • Reward points : 0
    • Joined: 2008/05/30 11:24:01
    • Location: Zelenograd, Russia
    • Status: offline
    Re: High-Speed PWM Odd Signal When Disabled 2019/06/19 02:14:43 (permalink)
    0
    You must control the PWMx pins behavior with IOCONx register.
    #4
    bassbreaker
    New Member
    • Total Posts : 3
    • Reward points : 0
    • Joined: 2019/06/12 13:50:05
    • Location: 0
    • Status: offline
    Re: High-Speed PWM Odd Signal When Disabled 2019/06/21 11:58:26 (permalink)
    0
    Thanks for the responses. I replaced the chip and things are working as expected. Maybe I killed the pin, bad solder job or maybe it was just a bad chip.
    Thanks anyways.
    #5
    Jump to:
    © 2019 APG vNext Commercial Version 4.5