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

i have a timer0 calculate Q?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
john.whung
Guest







i have a timer0 calculate Q?
PostPosted: Tue Jun 27, 2006 4:30 am     Reply with quote

#if defined(__PCM__)
#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) // Jumpers: 8 to 11, 7 to 12

#elif defined(__PCH__)
#include <18F452.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) // Jumpers: 8 to 11, 7 to 12
#endif

#define INTS_PER_SECOND 76 // (20000000/(4*256*256))

BYTE seconds; // A running seconds counter
BYTE int_count; // Number of interrupts left before a second has elapsed


#int_rtcc // This function is called every time
void clock_isr() { // the RTCC (timer0) overflows (255->0).
// For this program this is apx 76 times
if(--int_count==0) { // per second.
++seconds;
int_count=INTS_PER_SECOND;
}

}


void main() {

BYTE start;

int_count=INTS_PER_SECOND;
set_timer0(0);
setup_counters( RTCC_INTERNAL, RTCC_DIV_256 | RTCC_8_BIT);
enable_interrupts(INT_RTCC);
enable_interrupts(GLOBAL);

do {

printf("Press any key to begin.\n\r");
getc();
start=seconds;
printf("Press any key to stop.\n\r");
getc();
printf("%u seconds.\n\r",seconds-start);

} while (TRUE);

}






this code is a compiler's example.

What does it mean this expression: set_timer0(0); ?


Thanks
sjbaxter



Joined: 26 Jan 2006
Posts: 141
Location: Cheshire, UK

View user's profile Send private message Visit poster's website

PostPosted: Tue Jun 27, 2006 5:08 am     Reply with quote

It means exactly what is says .... set timer0 to a value of zero !!!

Try reading the CCS C Compiler help manual.
_________________
Regards,
Simon.
pin62426



Joined: 30 May 2006
Posts: 1

View user's profile Send private message

WHY?
PostPosted: Thu Jun 29, 2006 5:59 am     Reply with quote

setup_counters( RTCC_INTERNAL, RTCC_DIV_256 | RTCC_8_BIT);


THE code
setup_counters( RTCC_INTERNAL, RTCC_DIV_256 | RTCC_8_BIT);

What does it mean this expression ?
specifically, the "RTCC_DIV_256 | RTCC_8_BIT" mean?
how can i application code equation?
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Thu Jun 29, 2006 6:51 am     Reply with quote

Quote:


It means exactly what is says .... set timer0 to a value of zero !!!


All of the last beginners request are explained in the CCS Compiler Manual or in the Microchip Datasheets:

http://www.ccsinfo.com/downloads/ccs_c_manual.pdf

http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=64


Humberto
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