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

Problems with Full Bridge Configuration

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



Joined: 25 Nov 2005
Posts: 13
Location: San Diego

View user's profile Send private message Send e-mail Yahoo Messenger

Problems with Full Bridge Configuration
PostPosted: Sat Dec 10, 2005 2:50 am     Reply with quote

I am new to the CCS compiler and am having trouble setting up a full bridge controller.
Setup:
Compiler: PCWH 3.239
Chip: 18F4520
ICD: ICD-U40

I can't seem to get the Full Bridge PWM to work using the following code:
Code:

#include "D:\CCS\test4520B\PWM.h"
#define GREEN_LED PIN_A0

void main()
{

   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF|ADC_TAD_MUL_0);
   setup_psp(PSP_DISABLED);
   setup_spi(FALSE);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
   setup_timer_2(T2_DIV_BY_4,140,1);
   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   setup_low_volt_detect(FALSE);
   setup_oscillator(False);

       setup_ccp1(CCP_PWM_FULL_BRIDGE|CCP_SHUTDOWN_AC_H|CCP_SHUTDOWN_BD_L);

   set_pwm1_duty(70);

   while(true)
   {
      output_low (GREEN_LED);
      delay_ms (100);
      output_high (GREEN_LED);
      delay_ms (100);
   
   }

}


When I run this code nothing happens. The ECCP never seems to iniatialize.

I have implemented the ECCP full bridge in assembler before, but I was hoping that the above library function would set everything up for me and save a lot of time. When I watch in the debug menu it never writes to the CCP1CON register, which makes me think that I am not calling or initializing the function correctly. I read another posting:
http://www.ccsinfo.com/forum/viewtopic.php?t=23896&sid=66d21b94d00ac39f584746fa518d0487
He seemed to set the ECCP manually just like I have in assembler.

Is there a better way? Where am I supposed to go to find literature on how to use the ECCP functions within CCS? The "C Compiler" book that came with the software does not seem to cover this feature in much detail. Is there some other document that I am not looking at?

Thanks for your time, Mark.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Dec 10, 2005 1:16 pm     Reply with quote

I don't think CCS is setting it up correctly.

Here is the .LST file code:
Code:
.... setup_ccp1(CCP_PWM_FULL_BRIDGE|CCP_SHUTDOWN_AC_H|CCP_SHUTDOWN_BD_L); 
0018:  MOVLW  B7
001A:  ANDWF  FB1,F   // T3CON.3 and T3CON.6 = 0:  Use Timer 1
001C:  BSF    F94.2   // TRISC.2 = 1:  Set pin C2 = input
001E:  CLRF   FBD     // CCP1CON = 0 
0020:  MOVLW  40
0022:  MOVWF  FBD    // CCP1CON = 0x40:  Full Bridge forward mode

But the data sheet says for the Full Bridge mode:
Quote:
The TRISC<2> and TRISD<7:5> bits must be cleared to
make the P1A, P1B, P1C and P1D pins outputs.

They are setting TRISC.2 = 1 (it should be set = 0), and they're
not setting TRISD.5, 6, and 7 = 0 (They come up from reset = 1).
So the TRIS needs to be fixed. You can do that with the set_tris_x()
functions.
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