/////////////////////////////////////////////////////////////////////// //// EX_STWT.C //// //// //// //// 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. //// ///////////////////////////////////////////////////////////////////////
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 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; }
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);
}
Simple A/D
///////////////////////////////////////////////////////////////////////// //// EX_ADMM.C //// //// //// //// This program displays the min and max of 30 A/D samples over //// //// the RS-232 interface. The process is repeated forever. //// //// //// //// Configure the CCS prototype card as follows: //// //// Insert jumpers from: 11 to 17, 12 to 18 and 9 to 16 //// //// Use the #9 POT to vary the voltage. //// /////////////////////////////////////////////////////////////////////////