CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

18F4520 PWM1CON ECCP dead band delay

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
sunay



Joined: 04 Oct 2011
Posts: 3

View user's profile Send private message

18F4520 PWM1CON ECCP dead band delay
PostPosted: Tue Oct 04, 2011 8:03 am     Reply with quote

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
Ttelmah



Joined: 11 Mar 2010
Posts: 19383

View user's profile Send private message

PostPosted: Tue Oct 04, 2011 8:10 am     Reply with quote

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
sunay



Joined: 04 Oct 2011
Posts: 3

View user's profile Send private message

PostPosted: Tue Oct 04, 2011 10:15 am     Reply with quote

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
haseeb younus



Joined: 10 Feb 2014
Posts: 1

View user's profile Send private message

PostPosted: Mon Feb 10, 2014 1:30 pm     Reply with quote

Can you plz send me your code on my id harry.haseeb@gmail.com
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group