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

Compare problem

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



Joined: 21 Apr 2007
Posts: 1

View user's profile Send private message

Compare problem
PostPosted: Thu Oct 11, 2007 3:00 pm     Reply with quote

Hi.
I use version 4.023 and have a problem with cpp.(i think)
Quote:
#include <16F877.h>
#device adc=8

#FUSES NOWDT //No Watch Dog Timer
#FUSES XT //Crystal osc <= 4mhz
#FUSES NOPUT //No Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES BROWNOUT //Reset when brownout detected
#FUSES LVP //Low Voltage Programming on B3(PIC16) or B5(PIC18)
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD

#use delay(clock=4000000)
#include <stdlib.h>
//*****************************************************************************
int tim=1;
int16 ccp1_buf,ccp2_buf;
//*****************************************************************************
#int_RTCC
void RTCC_isr()
{
tim++;

if (tim==20)
{
output_high(PIN_C1);
output_high(PIN_C2);
setup_ccp1(CCP_COMPARE_CLR_ON_MATCH);
setup_ccp2(CCP_COMPARE_CLR_ON_MATCH);

CCP_1=ccp1_buf;
CCP_2=ccp2_buf;
set_timer1(0);
tim=0;

return;
}
if (tim==2)
{setup_ccp1(ccp_off);
setup_ccp2(ccp_off);
set_timer0(130);
return;}

}
//****************************************************************************
void main()
{

setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_4);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
setup_timer_2(T2_DISABLED,0,1);

ccp2_buf=1500;
ccp1_buf=1500;

enable_interrupts(INT_RTCC);
enable_interrupts(GLOBAL);


while(1)
{

}

}

When i compilied this code there no error. But the ccp1 and ccp2 pin only high for 1-2 us instead of 1.5 ms. Can you help with the code pls?
Kenny



Joined: 07 Sep 2003
Posts: 173
Location: Australia

View user's profile Send private message

PostPosted: Thu Oct 11, 2007 10:36 pm     Reply with quote

The CCP output latch is never set high!
The CCP latch is not the data latch. What is happening is that the the output pin is being set high by output_high() then immediately pulled low by setup_ccpx(CCP_COMPARE_CLR_ON_MATCH) because the default state of the CCP latch is low.

Don't switch between CCP mode and data mode.
Delete setup_ccpx(ccp_off);

Then to set the pin high, instead of output_high() use the technique shown in the CCS example EX_CCP1S.C

setup_ccp1(CCP_COMPARE_SET_ON_MATCH); // Configure CCP1 to set
CCP_1 = 0;
set_timer1(0); // C2 high now
Guest








PostPosted: Fri Oct 12, 2007 6:48 am     Reply with quote

thank you very much.. Now it's working properly.
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