#include #include void main( void ){ /* Main function */ unsigned char var = 1; /* initialize the counter to one */ unsigned char data; /* this is the variable that we will store the data from port A */ unsigned char RDRF = 0x20; /* the mask of the RDRF flag */ char dummy; /* the dummy variable used to clear the RDRF flag */ dummy=SCDR; /* empty the contents of the data register to clear the RDRF flag */ while((SCSR&RDRF)==0) /* While no key has been pressed toggle pin PA4 of port A */ { data=PORTA; /* put contents of port A into data so we can manipulate it */ data=data^0x10; /* toggle data using an exor operation */ PORTA=data; /* store data back into port A */ } dummy=SCDR; /* Empty the contents of the data register to clear the RDRF flag */ while((SCSR&RDRF)==0){ /* while no key has been pressed toggle pin PA4 of port A printiing "Iteration Number: var" incrimenting var until it reaches ten then reset itself to zero. */ if (var < 11){ /* if the counter is below ten print "iteration number:" and increment var printf("\nIteration Number: %d", var); var++; } else /* if the counter reaches ten then reset it to one. */ var = 1; } /********************* Print "Exit" and quit ********************/ printf("\n Exit") asm("SWI"); } /*********** EOF **********/