Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] DsPIC33EP PWM not functioning properly

Status
Not open for further replies.

Konric

Newbie level 3
Joined
Oct 24, 2015
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
47
Hi I am testing the functionality of the dsPIC33EP and ran some example code from the Family Reference Manual for the PWM module.
Here's the code:



Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
void PWMInit (void);
 
#include "xc.h"
#include "p33EP512MU814.h"
 
 
int main(void) {
    
    PWMInit (); 
    while (1);
    return 0;
}
 
void PWMInit (void)
{
/* Set PWM Periods on PHASEx Registers */
PHASE1 = 800;
PHASE2 = 900;
PHASE3 = 1000;
/* Set Duty Cycles */
PDC1 = 200;
PDC2 = 300;
PDC3 = 400;
/* Set Dead Time Values */
DTR1 = DTR2 = DTR3 = 0;
ALTDTR1 = ALTDTR2 = ALTDTR3 = 0;
/* Set PWM Mode to Redundant */
IOCON1 = IOCON2 = IOCON3 = 0xC400;
/* Set Independent Time Bases, Edge-Aligned Mode and Independent Duty Cycles */
PWMCON1 = PWMCON2 = PWMCON3 = 0x0200;
/* Configure Faults */
FCLCON1 = FCLCON2 = FCLCON3 = 0x0003;
/* 1:1 Prescaler */
PTCON2 = 0x0000;
/*Disable Chop*/
CHOP = 0;
/* Enable PWM Module */
PTCON = 0x8000;
}




And here is the Mplab logic analyzer

PWM.JPG

I have the chop function disabled but I am still getting a weird output for the duty cycle, it's not solid but keeps toggling furthermore it's not consistant sometimes on PWM1 the output toggle is very uniform in respect to the time on and off but then it starts to do two quick toggles followed by a longer off time.
Then there's the problem with PWM2 it toggles 5 times for a period of time and switches to 6 toggles.

Then if I increase the duty cycle to 90% I get the following output:

PWM2.JPG

Does anyone know what is going on?
I am doing everything in simulation mode, is there some kind of setting that I am missing?

Thanks
 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top