|
|
View previous topic :: View next topic |
Author |
Message |
john.whung Guest
|
i have a timer0 calculate Q? |
Posted: Tue Jun 27, 2006 4:30 am |
|
|
#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
|
|
Posted: Tue Jun 27, 2006 5:08 am |
|
|
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
|
WHY? |
Posted: Thu Jun 29, 2006 5:59 am |
|
|
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
|
|
|
|
|
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
|