/* main.c */ /* decimal counter with multiplexed output */ #pragma SMALL DB #include /* P0, P1, P2 and P3 are predefined port names and are bit addressable */ unsigned char SetDisplay(unsigned char value){ unsigned char LookupTable[11] = { 0xC0, ... }; /* check to see if "value" is in bounds */ if( ) { /* return appropriate value */ } else { /* return appropriate value */ } } /* Delay function */ void delay() { int i; for(i=0; i<1000; i++){ i = i + 0; } } void main(void){ unsigned char count = 0; /* holds value to be displayed */ unsigned long timer = 0; /* Holds the display so that it doesn't count to fast */ int turn = 1; /* indicates if we display the ones place or the tens place */ while(1) { if(turn){ /* configure P3 to turn on the one's place display */ /* display the one's value using P2*/ turn = 0; delay(); } else{ /* configure P3 to turn on the ten's place display */ /* display the ten's value using P2*/ turn = 1; delay(); } if(timer == 50){ /* update the count value */ /* The 'timer' variable controls how long a certain number is displayed */ /* When it displays a number--for example 12--fifty times, then you */ /* need to add the code to increment the counter so that it displays the */ /* next number--like 13--which will be displayed fifty times */ timer=0; } timer++; } }