View previous topic :: View next topic |
Author |
Message |
sunay
Joined: 04 Oct 2011 Posts: 3
|
18F4520 PWM1CON ECCP dead band delay |
Posted: Tue Oct 04, 2011 8:03 am |
|
|
Hello,
I've tried to design a microcontroller based half-bridge Mosfet circuit. I 'm using PIC18F4520 that has ECCP module on CCP1. I managed to create PWM signal with this CCP1 module on P1A and out of phase on P1B. Now I just want to make a delay between these PWM signals. I read this site's topics which includes PWM1CON and dead band delay. I used the code as below.
Code: |
void set_deadband(int8 deadband)
{
#byte PWM1CON = 0x9B
if(deadband > 127)
deadband = 127;
PWM1CON = deadband;
}
|
on its data sheet it says that DELAY=Tosc* PWM1CON
my Tosc =10^-7 and I want 1 us delay so 10^-6/10^-7=PWM1CON
PWM1CON=10 =0x0A
But when I look from the scope with X10 I coulnt catch the delay time :(
Why didnt I see the delay time ? do you have any idea?
with best regards,
sunay |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19383
|
|
Posted: Tue Oct 04, 2011 8:10 am |
|
|
PWM1CON, is _not_ at address 0x9B.
That looks like the address for a 16 chip, rather than a 18 chip.
Safest, use:
#byte PWM1CON=getenv("SFR:PWM1CON")
which will automatically put the right address in for you, to avoid this. PWM1CON on your chip is at 0xFB7.....
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
sunay
Joined: 04 Oct 2011 Posts: 3
|
|
Posted: Tue Oct 04, 2011 10:15 am |
|
|
you are absolutely right. I already missed PWM1CON address...
your correction has solved my problem.
#byte PWM1CON=getenv("SFR:PWM1CON")
Thanks for your quick help.
with kind regards,
Sunay |
|
![](templates/subSilver/images/spacer.gif) |
haseeb younus
Joined: 10 Feb 2014 Posts: 1
|
|
![](templates/subSilver/images/spacer.gif) |
|