How to use hardware PWM using PIC10f320

Status
Not open for further replies.

djc

Advanced Member level 1
Joined
Jan 27, 2013
Messages
402
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Location
India
Activity points
4,554
Hi,
I have several doubts regarding hardware PWM in PIC10f320. Datasheet says it has 2 PWM. Firstly, on which pin will PWM occur. RA0 or RA1? If i configure PWM for certain duty cycle, will that PWM occurs automatically on both the PWM pins RA0 and RA1? Will waveform on second pin be complemented of first PWM or do I have to make some other arrangements to do that. I have to drive two mosfets. I read datasheet again n again but i am unable to interpret it properly. Guidance needed.

Thank You
 

This sounds a bit like I could have read the datasheet, but may be I can save the effort?

Just look at the SFR map and realize that the processor has two sets of PWM registers to control the individual outputs.
 

Hai,
If you enable PWM1 you will get output at RA0, likewise if you configure PWM2 you will get output at RA1. You can enable respective PWM output pin in PWMxCON reg. For example, for enabling pwm1 (RA0)out make PWM1OUT=1. You can achieve complemented output by adjusting the pwm polarity.
 
Reactions: djc

    djc

    Points: 2
    Helpful Answer Positive Rating
Ok ok,
Thanks mukesh. Now i got that why 'x' is given in PWMxCON register. So we have to enable both PWM separately using PWM1CON and PWM2CON registers. Right. Sorry for my lame understanding. This is first time i am using hardware PWM. One more question, is timer 2 used for both PWM. If so, then timer setting used for PWM1 will be same for PWM2 apart from different register names, right? And do we have to clear timer2 interrupt flag? if it is, then for single PWM or both the PWM.
 
Last edited:

Yes TIMER2 is used for both PWMs , all settings are same for both modules. Pwm does not have any dependency with timer2 interrupt flag. It has dependency only with PR2 reg , PWMDCH, PWMDCL etc. The timer will get cleared when it becomes equal to PR2. So you don't have to clear the timer interrupt flag.
 
Reactions: djc

    djc

    Points: 2
    Helpful Answer Positive Rating
Hi mukesh.
Please clear one more doubt. Both the PWM will act simultaneously, right. Now when PWM1POL bit for PWM1 is '1' and PWM2POL bit for PWM2 is '0', means at the same time PWM2 will be complement of PWM1 or vice versa, right?
 

Both PWMs will have the same frequency as Timer2 is shared for both.
 

Thanks mukesh,
Now if we want to add dead time, what should we do? Does complementary waveform generator comes handy?
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…