El presente sitio presenta diseños y proyectos realizados con Solidworks y otros programas 3d , además de laminas y modelos 3d para practicar en casa, con el único objetivo de poder aprender y explorar la capacidad de Solidworks, no existiendo en ningún caso fines de lucro.
Friday, March 1, 2013
Contar segundos con el timer 0 CCS
Posted by Juan Francisco | Friday, March 1, 2013 | Category:
CODIGO CCS
|
///////////////////////////////////////////////////////////////////////
//// ////
//// This program uses the RTCC (timer0) and interrupts to keep a ////
//// real time seconds counter. A simple stop watch function is ////
//// then implemented. ////
//// ////
//// Configure the CCS prototype card as follows: ////
//// Insert jumpers from: 11 to 17 and 12 to 18. ////
///////////////////////////////////////////////////////////////////////
#include<16f877a .h="">16f877a>
#fuses HS,NOLVP,NOWDT,PUT
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)
#define high_start 76
byte seconds, high_count;
#INT_RTCC //Interrupt procedure
clock_isr() { //called every time RTCC
high_count -= 1; //flips from 255 to 0
if(high_count==0) {
++seconds;
high_count=high_start; //Inc SECONDS counter every
} //76 times to keep time
}
void main() { //a simple stopwatch program
byte start, time;
high_count = high_start;
setup_timer_0( RTCC_INTERNAL | RTCC_DIV_256 );
set_timer0(0);
enable_interrupts(INT_RTCC);
enable_interrupts(GLOBAL);
do {
printf("Press any key to begin.nr");
getc();
start = seconds;
printf("Press any key to stop.rn");
getc();
time = seconds - start;
printf("%U seconds.nr", time);
} while (TRUE);
}
Subscribe to:
Post Comments (Atom)
Currently have 0 comentarios: