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

how to add dead band delay with half bridge PWM with ccsc 5

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



Joined: 27 May 2015
Posts: 2

View user's profile Send private message

how to add dead band delay with half bridge PWM with ccsc 5
PostPosted: Wed May 27, 2015 2:31 pm     Reply with quote

i am the newer of ccsc with PIC, i would like to generate a half bridge PWM driver for test, but I dont know how to setup the dead band delay on ccsc. Could any help
Code:

#include <18F4550.h>
#device ADC=16

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)

#use delay(clock=48MHz,crystal=20000000)

#define LED PIN_B7
#define DELAY 50

#include <main.h>

void main()
{
   setup_timer_2(T2_DIV_BY_1,1,1);      //0.2 us overflow, 0.2 us interrupt

   setup_ccp1(CCP_PWM|CCP_PWM_HALF_BRIDGE|CCP_SHUTDOWN_AC_L|CCP_SHUTDOWN_BD_L);
   set_pwm1_duty((int16)4);

   //Example blinking LED program
   while(true)
   {
      output_low(LED);
      delay_ms(DELAY);
      output_high(LED);
      delay_ms(DELAY);
   }

}
Ttelmah



Joined: 11 Mar 2010
Posts: 19360

View user's profile Send private message

PostPosted: Wed May 27, 2015 2:49 pm     Reply with quote

add CCP_DELAY to your declaration, and put the value into the ECCP1DEL register. It's not explained properly, but this is the value that can optionally be placed _after_ the mode settings.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 27, 2015 10:14 pm     Reply with quote

If I compile your posted program with vs. 5.046, the compiler sets the deadband delay to 0, as shown below in the .LST file:
Code:

....................    setup_ccp1(CCP_PWM|CCP_PWM_HALF_BRIDGE|CCP_SHUTDOWN_AC_L|CCP_SHUTDOWN_BD_L); 
0046:  BCF    TRISC.TRISC2
0048:  BCF    LATC.LATC2
004A:  BCF    TRISD.5
004C:  MOVLW  8C
004E:  MOVWF  CCP1CON
0050:  [b]CLRF   ECCP1DEL[/b]  // Set deadband delay to 0
0052:  CLRF   ECCP1AS


The CCS manual says this:
Quote:
setup_ccp1 (mode, pwm)

pwm parameter is an optional parameter for chips that includes ECCP module. This parameter allows setting the shutdown time. The value may be 0-255.

But if I do this (with a parameter of 5, for example), I get code that sets
the ECCP1DEL register to 5. This is the deadband delay register.
Quote:

.................... setup_ccp1(CCP_PWM|CCP_PWM_HALF_BRIDGE|CCP_SHUTDOWN_AC_L|CCP_SHUTDOWN_BD_L, 5);
0046: BCF TRISC.TRISC2
0048: BCF LATC.LATC2
004A: BCF TRISD.5
004C: MOVLW 8C
004E: MOVWF CCP1CON
0050: MOVLW 05 // Set deadband delay to 5
0052: MOVWF ECCP1DEL
0054: CLRF ECCP1AS

I submit that the CCS manual is wrong, and that the 2nd parameter is
really the deadband delay. I am going to email them about this right now.
Ttelmah



Joined: 11 Mar 2010
Posts: 19360

View user's profile Send private message

PostPosted: Thu May 28, 2015 8:23 am     Reply with quote

Totally agree.
I did say "It's not explained properly, but this is the value that can optionally be placed _after_ the mode settings."

It has been mentioned here in the past in another thread, which is why I knew it was this value.
wings1122



Joined: 27 May 2015
Posts: 2

View user's profile Send private message

PostPosted: Fri May 29, 2015 11:30 am     Reply with quote

thank you all.
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