/************************************************************************ * Term: Fall 2003 * Course: ECE 473 * Name: Olamide Adabonyan * E-mail: o_mide@yahoo.com * * REVISION HISTORY * * First Draft: 9/24-26/02 * -while loops not working correctly because inchar() * functionstops program * date: 9/27/02 * -function to check input buffer coded and running * -PROGRAM COMPLETE... * * Date Submitted: 9/30/02 * Demo Approval: ________ ************************************************************************/ #include #define endProg() asm("swi") #define iteration_max 300 //max # of iterations char InChar(void); void iteration(void); main() { char input=0, temp; printf("Toggling PA4... Press any key to continue\n"); //RDRF set by default, so it must be cleared [chk pink book 4 instructions] temp = SCSR; temp = SCDR; while (input == 0) { PORTA = PORTA^0x10; input = InChar(); } iteration(); printf("\nProgram Complete..."); printf("\n\nOlamide Adabonyan"); printf("\n[ECE 473] | [lab #1-b] | [Sept 30, 2002]"); endProg(); } void iteration(void) { char input2 = 0; unsigned short iteration_num=1; while((iteration_num < (iteration_max + 1)) && (input2 == 0)) { PORTA ^= 0x10; printf("\nIteration Number: %d", iteration_num); ++iteration_num; input2 = InChar(); } } char InChar(void) { char temp; if((SCSR & 0x20)) temp = SCDR; else temp = 0; return(temp); }