int main(void){ TExaS_Init(SSI0_Real_Nokia5110_Scope); // set system clock to 80 MHz Random_Init(1); Output_Init(); ST7735_FillScreen(0x0000); // set screen to black ST7735_DrawBitmap(52, 159, PlayerShip0, 18,8); // player ship middle bottom ST7735_DrawBitmap(53, 151, Bunker0, 18,5); ST7735_DrawBitmap(0, 9, SmallEnemy10pointA, 16,10); ST7735_DrawBitmap(20,9, SmallEnemy10pointB, 16,10); ST7735_DrawBitmap(40, 9, SmallEnemy20pointA, 16,10); ST7735_DrawBitmap(60, 9, SmallEnemy20pointB, 16,10); ST7735_DrawBitmap(80, 9, SmallEnemy30pointA, 16,10); ST7735_DrawBitmap(100, 9, SmallEnemy30pointB, 16,10); Delay100ms(50); // delay 5 sec at 80 MHz ST7735_FillScreen(0x0000); // set screen to black ST7735_SetCursor(1, 1); ST7735_OutString("GAME OVER"); ST7735_SetCursor(1, 2); ST7735_OutString("Nice try,"); ST7735_SetCursor(1, 3); ST7735_OutString("Earthling!"); ST7735_SetCursor(2, 4); LCD_OutDec(1234); while(1){ } }
int main(void){// activate grader and set system clock to 80 MHz unsigned long NumberOfPresses = 0; // store the number of presses unsigned long LastInput = 0; // store the last input of Switch here TExaS_Init(SW_PIN_PA3, HEADPHONE_PIN_PA2,ScopeOn); Sound_Init(); EnableInterrupts(); // enable after all initialization are done while(1){ // main program is free to perform other tasks // do not use WaitForInterrupt() here, it may cause the TExaS to crash // perform other tasks - Read the input over and over again: Switch = GPIO_PORTA_DATA_R & 0x08; // read the switch from PA3 if (Switch != 0 && Switch != LastInput) { // if the switch is pressed, and last time it was released: NumberOfPresses++; // the number of the ACTUAL press increase by 1 } LastInput = Switch; // save the current input for next time if (NumberOfPresses%2 == 0) { // if the number of press is even // (those presses at the 0, 2nd, 4th, 6th,... time) GPIO_PORTA_DATA_R &= ~0x04; // then turn off PA2 } else { // if the number of press is odd // (those presses at the 1st, 3rd, 5th, 7th,... time) WaitForInterrupt(); // then periodically interrupt the system each 880 Hz // the SysTick will automatically // trigger itself every (1 s)/(880 Hz) = 1.13636 ms } } }
int main(void){ unsigned long i,last,now, SW1, SW2; TExaS_Init(SW_PIN_PF40, LED_PIN_PF1); // activate grader and set system clock to 16 MHz PortF_Init(); // initialize PF1 to output SysTick_Init(); // initialize SysTick, runs at 16 MHz i = 0; // array index last = NVIC_ST_CURRENT_R; EnableInterrupts(); // enable interrupts for the grader while(1){ SW1= GPIO_PORTF_DATA_R & 0x01; SW2= GPIO_PORTF_DATA_R & 0x10; if(!SW1 || !SW2) { Led = GPIO_PORTF_DATA_R; // read previous Led = Led^0x02; // toggle red LED GPIO_PORTF_DATA_R = Led; // output if(i<50){ now = NVIC_ST_CURRENT_R; Time[i] = (last-now)&0x00FFFFFF; // 24-bit time difference //Data[i] = GPIO_PORTF_DATA_R&0x02; // record PF1 Data[i] = GPIO_PORTF_DATA_R&0x13; // record PF1 last = now; i++; } Delay(); } else { GPIO_PORTF_DATA_R &=~0x02 ; // output } } }
int main(void){ unsigned long volatile delay; unsigned long In; TExaS_Init(SW_PIN_PF4, LED_PIN_PF2); // activate grader and set system clock to 80 MHz // initialization goes here PortF_Init(); EnableInterrupts(); // enable interrupts for the grader GPIO_PORTF_DATA_R = 0x04; while(1){ // body goes here Delay100ms(1); In = GPIO_PORTF_DATA_R&0x10; if(In == 0x00) { //Switch is pressed toggel PF2 GPIO_PORTF_DATA_R = GPIO_PORTF_DATA_R ^ (1 << 2); } else { //Switch is not pressed, set PF2 to on GPIO_PORTF_DATA_R = 0x04; } } }
int main(void){ unsigned long volatile delay; TExaS_Init(SW_PIN_PF4, LED_PIN_PF2); // activate grader and set system clock to 80 MHz // initialization goes here SYSCTL_RCGC2_R |= 0x00000020; // 1) activate clock for Port F delay = SYSCTL_RCGC2_R; // allow time for clock to start // GPIO_PORTF_LOCK_R = 0x4C4F434B; // 2) unlock GPIO Port F // GPIO_PORTF_CR_R = 0x1F; // allow changes to PF4-0 // only PF0 needs to be unlocked, other bits can't be locked GPIO_PORTF_AMSEL_R &= ~0x14; // 3) disable analog on PF2,4 GPIO_PORTF_PCTL_R &= ~0x000F0F00; // 4) PCTL GPIO on PF2,4 GPIO_PORTF_DIR_R &= ~0x10; // 5) PF4 in, GPIO_PORTF_DIR_R |= 0x04; // PF2 out GPIO_PORTF_AFSEL_R &= ~0x14; // 6) disable alt funct on PF7-0 GPIO_PORTF_PUR_R |= 0x10; // enable pull-up on PF4 GPIO_PORTF_DEN_R = 0x14; // 7) enable digital I/O on PF2,4 GPIO_PORTF_DATA_R |= 0x04; // set pf2 on EnableInterrupts(); // enable interrupts for the grader while(1){ // body goes Delay100ms(1); if(GPIO_PORTF_DATA_R&0x10) GPIO_PORTF_DATA_R |= 0x04; if(!(GPIO_PORTF_DATA_R&0x10)) GPIO_PORTF_DATA_R ^= 0x04; } }
// *************************** Capture image dimensions out of BMP********** int main(void){ TExaS_Init(SSI0_Real_Nokia5110_Scope); // set system clock to 80 MHz Random_Init(69); Output_Init(); ADC0_Init(); ST7735_InvertDisplay(0); ST7735_SetRotation(0); AI_Init(0x07); Player_Init(); player.potato=1; Timer0_Init(Master_Funk, 30); ST7735_DrawBitmap(53, 151, Bunker0, 18,5); // Delay100ms(1); // delay 5 sec at 80 MHz /* ST7735_FillScreen(0x0000); // set screen to black ST7735_SetCursor(1, 1); ST7735_OutString("GAME OVER"); ST7735_SetCursor(1, 2); ST7735_OutString("Nice try,"); ST7735_SetCursor(1, 3); ST7735_OutString("Earthling!"); ST7735_SetCursor(2, 4); LCD_OutDec(1234); */ while(1){ } }
int main1(void){ // single step this program and look at Data TExaS_Init(); // Bus clock is 80 MHz ADC_Init(); // turn on ADC, set channel to 1 while(1){ Data = ADC_In(); // sample 12-bit channel 1 } }
int main(void){ DisableInterrupts(); TExaS_Init(SSI0_Real_Nokia5110_Scope); // set system clock to 80 MHz Random_Init(1); Nokia5110_Init(); PF1Init(); //SysTick_Init(2666666); //Initialize SysTick with 30 Hz interrupts SysTick_Init(2666666*4); //Increased period by 4 for actual hardware to make the game run at a playable speed Nokia5110_ClearBuffer(); Nokia5110_DisplayBuffer(); // draw buffer ADC0_Init(); Game_Init(); SwitchLed_Init(); Sound_Init(); Timer2_Init(&Sound_Play,7256); //11.025 kHz. 80,000,000/11,025 cycles, which is about 7256 GameOverFlag = 0; EnableInterrupts(); while(1){ while(Semaphore==0){}; Semaphore = 0; if(GameOverFlag){ State_GameOver(); } else{ Draw_GameFrame(); // update the LCD } if((GameOverFlag == 0) && (Check_GameOver())){ //just detected game over Delay100ms(2);//Delay 200ms GameOverFlag = Check_GameOver(); //SysTick_Init(2666666);//Re-initialize with 30 Hz interrupt SysTick_Init(2666666*4); //Increased period by 4 for actual hardware to make the game run at a playable speed } } }
int main(void){ TExaS_Init(SSI0_Real_Nokia5110_Scope); // set system clock to 80 MHz Random_Init(1); Nokia5110_Init(); Nokia5110_ClearBuffer(); Nokia5110_DisplayBuffer(); // draw buffer Nokia5110_PrintBMP(32, 47, PlayerShip0, 0); // player ship middle bottom Nokia5110_PrintBMP(33, 47 - PLAYERH, Bunker0, 0); Nokia5110_PrintBMP(0, ENEMY10H - 1, SmallEnemy10PointA, 0); Nokia5110_PrintBMP(16, ENEMY10H - 1, SmallEnemy20PointA, 0); Nokia5110_PrintBMP(32, ENEMY10H - 1, SmallEnemy20PointA, 0); Nokia5110_PrintBMP(48, ENEMY10H - 1, SmallEnemy30PointA, 0); Nokia5110_PrintBMP(64, ENEMY10H - 1, SmallEnemy30PointA, 0); Nokia5110_DisplayBuffer(); // draw buffer Delay100ms(50); // delay 5 sec at 50 MHz Nokia5110_Clear(); Nokia5110_SetCursor(1, 1); Nokia5110_OutString("GAME OVER"); Nokia5110_SetCursor(1, 2); Nokia5110_OutString("Nice try,"); Nokia5110_SetCursor(1, 3); Nokia5110_OutString("Earthling!"); Nokia5110_SetCursor(2, 4); Nokia5110_OutUDec(1234); while(1){ } }
int main(void){ volatile unsigned long delay; //TExaS_Init(ADC0_AIN1_PIN_PE2, SSI0_Real_Nokia5110_NoScope); TExaS_Init(ADC0_AIN1_PIN_PE2, SSI0_Real_Nokia5110_Scope); ADC0_Init(); // initialize ADC0, channel 1, sequencer 3 Nokia5110_Init(); // initialize Nokia5110 LCD SysTick_Init(1999999); // initialize SysTick for 40 Hz interrupts // initialize profiling on PF1 (optional) // wait for clock to stabilize SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOF; // activate port F delay = SYSCTL_RCGC2_R; GPIO_PORTF_DIR_R |= 0x04; // make PF2 out (built-in LED) GPIO_PORTF_AFSEL_R &= ~0x04; // disable alt funct on PF2 GPIO_PORTF_DEN_R |= 0x04; // enable digital I/O on PF2 // configure PF2 as GPIO GPIO_PORTF_PCTL_R = (GPIO_PORTF_PCTL_R&0xFFFFF0FF)+0x00000000; GPIO_PORTF_AMSEL_R = 0; // disable analog functionality on PF EnableInterrupts(); Nokia5110_Clear(); Nokia5110_OutString((unsigned char *)"UT.6.01x Lab 14 Start"); while(1){ if(Flag) { UART_ConvertDistance(Distance); Nokia5110_SetCursor(0, 3); Nokia5110_OutString(String); Flag = 0; } } }
int main(void){ //Initialize all below: TExaS_Init(); // Bus clock is 80 MHz ADC_Init(); // initialize to sample ADC1 ST7735_InitR(INITR_REDTAB); SysTick_Init(); UART_Init(); FiFo_Init(); PortF_Init(); EnableInterrupts(); while(1){ while(ADCStatus == 0){}; //Poll ADCStatus flag ADCStatus = 0; //clear flag //Prints from a full FIFO --> BUT must know when //we get to the end --> uses while loop to check this condition, //and a for loop to print 5 times ST7735_SetCursor(6,5); //Infinite loop if the fifo is empty / if returns fail while (FiFo_Get(&data) == 0) {}; FiFo_Get(&data); for(int i = 1; i <= 5; i++){ ST7735_OutChar(data); FiFo_Get(&data); } FiFo_Get(&data); FiFo_Get(&data); ST7735_SetCursor(12,5); ST7735_OutString(" cm"); // print " cm" } }
int main(void){ TExaS_Init(SW_PIN_PE3210,DAC_PIN_PB3210,ScopeOn); // bus clock at 80 MHz //Timer0A_Init(&songTask, F80HZ); Piano_Init(); Sound_Init(0); DAC_Init(); Heartbeat_Init(); // other initialization EnableInterrupts(); uint32_t input; while(1){ GPIO_PORTF_DATA_R ^= 0x04; input = Piano_In(); if (input == 0x04){ Sound_Play(A); } else if (input == 0x02){ Sound_Play(C); } else if (input == 0x01){ Sound_Play(Eb); } else if (input == 0x07){ Sound_Play(A); } else { Sound_Play(0); } } }
int main(void){ TExaS_Init(); // Bus clock is 80 MHz ST7735_InitR(INITR_REDTAB); PortF_Init(); ADC_Init(); // turn on ADC, set channel to 1 SysTick_Init(); //Initialize SysTick for(;;){ while(ADCStatus == 0){} //Poll ADCStatus flag uint32_t x = ADCMail; //read ADCMail (input) ADCStatus = 0; //clear flag x = Convert(x); //convert the input ST7735_SetCursor(1,7); ST7735_OutString("D = "); //print "D = " ST7735_SetCursor(5,7); LCD_OutFix(x); // print the fixed point value ST7735_SetCursor(10,7); ST7735_OutString(" cm"); // print " cm" ///////////////////// ST7735_SetCursor(1,2); ST7735_OutString("Lab 8:"); ST7735_SetCursor(1,3); ST7735_OutString("Measurment of"); ST7735_SetCursor(1,4); ST7735_OutString("Distance :)"); } }
int main(void){ // for the real board grader to work, you must connect PD3 to your DAC output int piano; // to read current piano keys int prevPiano; // to store piano keys in prev cycle TExaS_Init(SW_PIN_PE3210, DAC_PIN_PB3210,ScopeOn); // activate grader and set system clock to 80 MHz Sound_Init(); // initialize SysTick timer and DAC Piano_Init(); EnableInterrupts(); // enable after all initialization are done while(1){ piano = Piano_In(); if(piano != prevPiano){ // only react if piano keys pressed if(piano == 0x00) Sound_Off(); else if(piano == 0x01) Sound_Tone(2389); else if(piano == 0x02) Sound_Tone(2128); else if(piano == 0x04) Sound_Tone(1896); else if(piano == 0x08) Sound_Tone(1594); delay(10); } prevPiano = piano; } }
// 3. Subroutines Section // MAIN: Mandatory for a C Program to be executable int main(void){ TExaS_Init(SW_PIN_PF40, LED_PIN_PF31,ScopeOn); // activate grader and set system clock to 80 MHz PortF_Init(); // Init port PF4 PF3 PF1 EnableInterrupts(); // enable interrupts for the grader while(1){ SetReady(); WaitForASLow(); ClearReady(); Delay1ms(10); WaitForASHigh(); Delay1ms(250); SetVT(); Delay1ms(250); ClearVT(); // Follows the nine steps list above // a) Ready signal goes high // b) wait for switch to be pressed // c) Ready signal goes low // d) wait 10ms // e) wait for switch to be released // f) wait 250ms // g) VT signal goes high // h) wait 250ms // i) VT signal goes low } }
int main(void){ // Real Lab13 // for the real board grader to work // you must connect PD3 to your DAC output TExaS_Init(SW_PIN_PE3210, DAC_PIN_PB3210,ScopeOn); // activate grader and set system clock to 80 MHz // PortE used for piano keys, PortB used for DAC Sound_Init(); // initialize SysTick timer and DAC Piano_Init(); EnableInterrupts(); // enable after all initialization are done DAC_Init(); while(1){ volatile unsigned long current_switch; current_switch = Piano_In(); if (current_switch == 0x01){ EnableInterrupts(); Sound_Tone(4780); } else if (current_switch == 0x02){ EnableInterrupts(); Sound_Tone(4259); } else if (current_switch == 0x04){ EnableInterrupts(); Sound_Tone(3794); } else if (current_switch == 0x08){ EnableInterrupts(); Sound_Tone(3189); } // else if (current_switch == 0x00){ // Sound_Off(); // DisableInterrupts(); // } delay(10); } }
int main(void){ unsigned long volatile delay; TExaS_Init(SW_PIN_PF4, LED_PIN_PF2); // activate grader and set system clock to 80 MHz // initialization goes here SYSCTL_RCGC2_R = SYSCTL_RCGC2_R | SYSCTL_RCGC2_GPIOF; // eja :::: Turn on the clock for PortF. delay = SYSCTL_RCGC2_R; // eja :::: give clock time to stablize. GPIO_PORTF_AMSEL_R = GPIO_PORTF_AMSEL_R & ~0x14; // eja :::: clear bits 4(switch 1) and 2(blue led) in the AMSEL registor. GPIO_PORTF_PCTL_R = GPIO_PORTF_PCTL_R & ~0x000F0F00; // eja :::: clear pins PF4 and PF2 in the P control registor to configure as GPIO. GPIO_PORTF_DIR_R = 0x0E; // eja :::: set bits 4 and 0 and clear bits 3, 2, and 1 in the direction registor. GPIO_PORTF_AFSEL_R = 0x0000; // eja :::: clear all bits in the AFSEL registor. GPIO_PORTF_DEN_R = 0x1F; // eja :::: enable digital for pins PF4, PF3, PF2, PF1, PF0. GPIO_PORTF_PUR_R = 0x11; //eja :::: enable pullup resistors for PF4, PF3, PF2, PF1, PF0. GPIO_PORTF_DATA_R = GPIO_PORTF_DATA_R | 0x04; // eja :::: set bit 2 in the data registor to turn led on. EnableInterrupts(); // enable interrupts for the grader while(1){ // body goes here Delay100ms(1); //eja :::: waits 100ms. in = GPIO_PORTF_DATA_R&0x10; //eja :::: reads value of PF4 into in. if (in == 0) { //eja :::: conditional if statement testing if the value of in is 0. GPIO_PORTF_DATA_R = GPIO_PORTF_DATA_R ^ 0x04; //eja :::: toggle bit 2(blue led) } //eja :::: ending of if statement and test. if (in == 1) { //eja :::: conditional if statement testing if the value of in is 1. GPIO_PORTF_DATA_R = GPIO_PORTF_DATA_R | 0x04; // eja :::: set bit 2 so as to turn led on. } //eja :::: end of if statement and test. } }
// *************************** Capture image dimensions out of BMP********** int main(void){ TExaS_Init(SSI0_Real_Nokia5110_Scope); // set system clock to 80 MHz Output_Init(); ADC0_Init(); DAC_Init(); SysTick_Init(); Menu_Init(); Sound_Init(); UART1_Init(); Button0_Init(); Timer0_Init(Play, 80000000/11025); // 11.025 kHz 80000000/11025 Timer1_Init(Master_Funk, 80000000/60); //Timer2_Init(SomeUART function, high speed); //for UART /* ST7735_FillScreen(0x0000); // set screen to black ST7735_SetCursor(1, 1); ST7735_OutString("GAME OVER"); ST7735_SetCursor(1, 2); ST7735_OutString("Nice try,"); ST7735_SetCursor(1, 3); ST7735_OutString("Earthling!"); ST7735_SetCursor(2, 4); LCD_OutDec(1234); */ while(1){ } }
// once the ADC and convert to distance functions are operational, // you should use this main to build the final solution with interrupts and mailbox int main(void){ TExaS_Init(ADC0_AIN1_PIN_PE2, SSI0_Real_Nokia5110_Scope); //ADC0_Init(); // initialize ADC0, channel 1, sequencer 3 Nokia5110_Init(); // initialize Nokia5110 LCD (optional) //SysTick_Init(1999999); // initialize SysTick for 40 Hz interrupts Flag = 0; EnableInterrupts(); // print a welcome message (optional) //Nokia5110_Clear(); //Nokia5110_OutString((unsigned char *)"UT.6.01x Lab 14 Start"); Nokia5110_Clear(); Nokia5110_SetCursor(0, 0); Nokia5110_OutString("Tekstiseina"); while(1){ // read mailbox //if (Flag == 1) { //Flag = 0; //ADCdata = ADC0_In(); //Distance = Convert(ADCdata) + 1; //UART_ConvertDistance(Distance); // from Lab 11 //Nokia5110_Clear(); //Nokia5110_SetCursor(0, 0); //Nokia5110_OutString(String); // output to Nokia5110 LCD (optional) //UART_OutString(String); //UART_OutString("\n"); //} } }
// main1 is a simple main program allowing you to debug the ADC interface int main1(void){ TExaS_Init(ADC0_AIN1_PIN_PE2, UART0_Emulate_Nokia5110_NoScope); ADC0_Init(); // initialize ADC0, channel 1, sequencer 3 EnableInterrupts(); while(1){ ADCdata = ADC0_In(); } }
int main(void){ TExaS_Init(SW_PIN_PE210, LED_PIN_PB543210,ScopeOff); // activate grader and set system clock to 80 MHz EnableInterrupts(); while(1){ } }
int main1(void){ TExaS_Init(); ADC_Init(); // turn on ADC, set channel to 1 ST7735_InitR(INITR_REDTAB); PortF_Init(); SysTick_Init(); // This makes things work UART1_Init(); while(1){} // do-nothing loop }
int main1(void){ // Modular test function for ADC drivers in ADC.h TExaS_Init(ADC0_AIN1_PIN_PE2, SSI0_Real_Nokia5110_Scope); ADC0_Init(); // initialize ADC0, channel 1, sequencer 3 EnableInterrupts(); while(1){ ADCdata = ADC0_In(); } }
int main(void){ TExaS_Init(SSI0_Real_Nokia5110_Scope); // set system clock to 80 MHz DisableInterrupts(); Random_Init(1); Nokia5110_Init(); Nokia5110_ClearBuffer(); Nokia5110_DisplayBuffer(); SysTick_Init(); // initialize Timer2 after Nokia5110_Init because of // error-prone registers operations (old and new registers // are not working good together) // 80MHz/11,025 cycles, which is about 7256 Timer2_Init(7256); Ports_Init(); InitSprites(NumberOfEnemies); RestartGame(); // Countdown, after which all interrupts are enabled! // print 3 Nokia5110_ClearBuffer(); Nokia5110_PrintBMP(28, 41, _my_Countdown_03, 0); Nokia5110_DisplayBuffer(); Delay100ms(3); // print 2 Nokia5110_ClearBuffer(); Nokia5110_PrintBMP(28, 41, _my_Countdown_02, 0); Nokia5110_DisplayBuffer(); Delay100ms(3); // print 1 Nokia5110_ClearBuffer(); Nokia5110_PrintBMP(28, 41, _my_Countdown_01, 0); Nokia5110_DisplayBuffer(); Delay100ms(3); // print GO Nokia5110_ClearBuffer(); Nokia5110_PrintBMP(28, 41, _my_Countdown_GO, 0); Nokia5110_DisplayBuffer(); Delay100ms(3); EnableInterrupts(); while(1){ if (Flag == 1) { Nokia5110_DisplayBuffer(); Flag = 0; } } }
int main(void){ n = 0; TExaS_Init(SW_PIN_PA5432, DAC_PIN_PB3210,SCOPE); // activate grader DAC_Init(); // your code to initialize the DAC EnableInterrupts(); while(1){ DAC_Out(n); // your code to output to the DAC delay(1000); // wait 1s (later change this to 1ms) n = (n+1)&0x0F; } }
// 3. Subroutines Section // MAIN: Mandatory for a C Program to be executable int main(void){ TExaS_Init(SW_PIN_PF40, LED_PIN_PF321); // activate grader and set system clock to 80 MHz PortF_Init(); // Init port PF4 PF2 PF0 EnableInterrupts(); // enable interrupts for the grader while(1){ SW1_2 = GPIO_PORTF_DATA_R&0x11; while (SW1_2==0){ FlashSOS(); SW1_2 = GPIO_PORTF_DATA_R&0x11; // PF0 into SW1 and SW2 } } }
{ RG, S, 50, { S_gn, S_yn, S_gn, S_yn, S_yn, S_yn, S_yn, S_yn } }, //North green { RY, S, 10, { S_wa, S_ge, S_gn, S_ge, S_wa, S_wa, S_wa, S_wa } } //North yellow - Move to wa }; void set_lights_and_wait(int state) { FSMType fState = FSM[state]; GPIO_PORTB_DATA_R = fState.out; GPIO_PORTF_DATA_R = fState.out_walk; SysTick_Wait10ms(FSM[state].time); }
// once the ADC is operational, you can use main2 to debug the convert to distance int main2(void){ TExaS_Init(ADC0_AIN1_PIN_PE2, UART0_Emulate_Nokia5110_NoScope); ADC0_Init(); // initialize ADC0, channel 1, sequencer 3 Nokia5110_Init(); // initialize Nokia5110 LCD EnableInterrupts(); while(1){ ADCdata = ADC0_In(); Nokia5110_SetCursor(0, 0); Distance = Convert(ADCdata); UART_ConvertDistance(Distance); // from Lab 11 Nokia5110_OutString(String); // output to Nokia5110 LCD (optional) } }
// PE0, PB0, or PA2 connected to positive logic momentary switch using 10 k ohm pull down resistor // PE1, PB1, or PA3 connected to positive logic LED through 470 ohm current limiting resistor // To avoid damaging your hardware, ensure that your circuits match the schematic // shown in Lab8_artist.sch (PCB Artist schematic file) or // Lab8_artist.pdf (compatible with many various readers like Adobe Acrobat). int main(void){ //********************************************************************** // The following version tests input on PE0 and output on PE1 //********************************************************************** TExaS_Init(SW_PIN_PE0, LED_PIN_PE1); // activate grader and set system clock to 80 MHz EnableInterrupts(); // enable interrupts for the grader while(1){ } }
// ***** 3. Subroutines Section ***** int main (void) { unsigned long length, width, area; TExaS_Init(UART_PIN_PA0,UART_PIN_PA1); // this initializes the TExaS grader lab 5 UART_Init(); // initialize UART for printing printf("\nThis program calculates areas of rectangular rooms.\n"); EnableInterrupts(); // the grader needs interrupts while(1) { printf("\nGive length: "); scanf("%ld", &length); // Get input printf("\nGive width: "); scanf("%ld", &width); // Get input area = Calc_Area(length, width); printf("\nArea of the room = %ld\n", area); } }