1
\$\begingroup\$

I'm trying to get the High Speed PWM Module from a dsPIC33EP64GS502 to work. I previously got working the same module for a dsPIC33FJ16GS402 but I can't get this one to work. The PIC is running at 70 MIPS with internal oscillator, the PWM frequency is 300KHz with a 50% duty, this is my code:

// ACLK setup
ACLKCONbits.FRCSEL = 1;
ACLKCONbits.SELACLK = 1;
ACLKCONbits.APSTSCLR = 7;
ACLKCONbits.ENAPLL = 1;
while(ACLKCONbits.APLLCK != 1);
// PWM setup
PTCONbits.PTEN = 0;
PTCONbits.PTSIDL = 0;
PTCONbits.SEIEN = 0;
PTCONbits.EIPU = 0;
PTCONbits.SYNCPOL = 0;
PTCONbits.SYNCOEN = 0;
PTCONbits.SYNCEN = 0;
PTCON2bits.PCLKDIV = 0;
PWMH_TRIS = PWML_TRIS = 1;
PWMCON1bits.FLTIEN = 0;
PWMCON1bits.CLIEN = 1;
PWMCON1bits.TRGIEN = 0;
PWMCON1bits.ITB = 1;
PWMCON1bits.MDCS = 0;
PWMCON1bits.DTC = 0;
PWMCON1bits.CAM = 0;
PWMCON1bits.XPRES = 0;
PWMCON1bits.IUE = 0;
TRIG1 = 1568; 
TRGCON1bits.DTM = 0;
TRGCON1bits.TRGSTRT = 0;
TRGCON1bits.TRGDIV = 5;
IOCON1bits.PENH = 0;
IOCON1bits.PENL = 0;
IOCON1bits.POLH = 0;
IOCON1bits.POLL = 0;
IOCON1bits.PMOD = 0;
IOCON1bits.SWAP = 0;
IOCON1bits.OSYNC = 0;
PHASE1 = 3136; // 300KHz
PDC1 = SDC1 = 1568; // 50%
DTR1 = 157;
ALTDTR1 = 157;
// Override
IOCON1bits.OVRDAT = 0;
IOCON2bits.OVRDAT = 0;
IOCON1bits.OVRENH = 1; IOCON1bits.OVRENL = 1;
PTCONbits.PTEN = 1;
IOCON1bits.OVRENH = 0; IOCON1bits.OVRENL = 0;
__delay_us(100);
IOCON1bits.PENH = 1;
IOCON1bits.PENL = 1;

I get absolutely nothing on PWM1H and PWM1L pins. I just don't know what else to change to make it work. This is intended to work in a synchronous buck converter so the signals are complementary.

asked Jul 28, 2017 at 10:38
\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

the I/O settings is set as input :

PWMH_TRIS = PWML_TRIS = 1;

PIC microcontrollers use 1 for input 0 for output .

answered Jul 28, 2017 at 11:15
\$\endgroup\$
1
  • \$\begingroup\$ If you change it to 0 to make them an output it doesn't work neither. The PWM module takes ownership of the outputs so the TRIS register settings doesn't matter at all \$\endgroup\$ Commented Jul 28, 2017 at 11:17
1
\$\begingroup\$

Ok, with the help of this post I finally solved it! I just had to disable the fault and current-limit inputs:

FCLCON1 = 0;
FCLCON1bits.FLTMOD = 3;
answered Jul 28, 2017 at 22:08
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.