/***************************************************************** * sinewave.c - main for sinewave example * Illustrate a simple use of the real time interrupt mechanism ****************************************************************/ #include "includes.h" #define COUNTT 2 volatile int count = COUNTT; int list[]={1,4,6,7,7,6,4,1,-1,-4,-6,-7,-7,-6,-4,-1}; int phase = 0; void main(void) { int done = 0, lub; RTICTL = 0x81; // setup the RTI timer to minimum delay PORTDLC = 0x00; // initialize port register DDRDLC = 0x04; // set pin to output CLI(); // enable I-class interrupts while (!done){ // determine current output lub = (phase >> 12)&0x0F; PORTDLC = list[lub]; // update the phase phase = (phase + 1)&0xFF; DelayGate(); } } /******************************************************** * DelayGate * Wait for some time *******************************************************/ void DelayGate(void) { while (count > 0); count = COUNTT; } /******************************************************** * An ISR for the real time clock *******************************************************/ #pragma TRAP_PROC void RtiIsr(void) { RTIFLG = 0x80; --count; }