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

ECCP1 PIC18LF45k50

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



Joined: 10 Nov 2016
Posts: 6

View user's profile Send private message

ECCP1 PIC18LF45k50
PostPosted: Thu Nov 10, 2016 3:09 am     Reply with quote

Hello,

I need your help regard activating ECCP1 @ RD5/P1B at PIC18LF45K50.

I saw this thread: https://www.ccsinfo.com/forum/viewtopic.php?p=105632

with the code inside, but i dont have a success to adjust the coreect registers i assume.

Thank you
Ttelmah



Joined: 11 Mar 2010
Posts: 19257

View user's profile Send private message

PostPosted: Thu Nov 10, 2016 3:32 am     Reply with quote

Old question. _What compiler version_.

The thread you point to, is very old, and was before the compiler had got ECCP support sorted on that particular chip. If your compiler is anything more modern, then the standard functions work.

The only mode that gives you P1B, without any other CCP1 pin activated, is full bridge reverse. If you don't want the other pins, you would have to use the output override functions.
mvme5100



Joined: 10 Nov 2016
Posts: 6

View user's profile Send private message

ECCP1 PIC18LF45k50
PostPosted: Thu Nov 10, 2016 4:45 am     Reply with quote

Hello

The compiler is 5.064 .

If i'm using this code then the regular CCP1 and CCP2 are working.

But the P1B and P1C arent.

Code:

#include <18lf45k50.h>
#Device ADC=10
#Device ICD=TRUE

#define XTAL_FREQUENCY   4000000
#define TIMER1_FREQUENCY (XTAL_FREQUENCY / 4)     

#fuses INTRC_IO,NOPROTECT
//#define DEEP_SLEEP   3
 #use delay (clock=4000000)
//#use delay(clock=40M)

#use i2c(master, sda=EEPROM_SDA, scl=EEPROM_SCL, SLOW)
#use rs232(baud = 9600, xmit=PIN_C6, rcv = PIN_C7, stream=STREAM_USER_UART, timeout=200)

               
 void main()
{

   printf("\n\r ====================== ");
   printf("\n\r ====== POWER ON ====== ");
   printf("\n\r ====================== \n\r");

   SETUP_WDT (WDT_OFF);
   setup_comparator(NC_NC_NC_NC);
   setup_timer_2(T2_DIV_BY_16,255,1); // For PWM 4Mhz crystal
   //setup_timer_1(T1_INTERNAL|T3_DIV_BY_4);

   //enable_interrupts(GLOBAL);
   //enable_interrupts(INT_USB);

while (1)  {
 
   setup_ccp1(CCP_PWM_L_L);
   set_pwm1_duty(100); /// 0 - 255
 
   setup_ccp2(CCP_PWM_L_L);
   set_pwm2_duty(100); /// 0 - 255

   }
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19257

View user's profile Send private message

PostPosted: Thu Nov 10, 2016 5:28 am     Reply with quote

It would. You are only in simple PWM mode. This only drives the 'A' pins/

The L_L setting sets the polarity for the signals, not the operating mode of the PWM.

Look at the data sheet. PWM output diagrams. Figure 15-6. If you want both modulated, you need half bridge. So:
Code:

setup_ccp1(CCP_PWM_HALF_BRIDGE | CCP_PWM_L_L);
mvme5100



Joined: 10 Nov 2016
Posts: 6

View user's profile Send private message

ECCP1 PIC18LF45k50
PostPosted: Thu Nov 10, 2016 5:41 am     Reply with quote

Great, got the idea.

Thank you so much
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