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 main3(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(); // This makes things work while(1){ //SysTick_Wait(2000000); PF2 ^= 0x04; // Heartbeat Data = ADC_In(); // sample 12-bit channel 1 PF3 = 0x08; // Profile Convert Position = Convert(Data); PF3 = 0; // end of Convert Profile PF1 = 0x02; // Profile LCD ST7735_SetCursor(0,0); LCD_OutFix(Data); ST7735_OutString(" "); ST7735_SetCursor(6,0); LCD_OutFix(Position); PF1 = 0; // end of LCD Profile } }
int main2(void){ TExaS_Init(); // Bus clock is 80 MHz ADC_Init(); // turn on ADC, set channel to 1 ST7735_InitR(INITR_REDTAB); PortF_Init(); while(1){ // use scope to measure execution time for ADC_In and LCD_OutDec PF2 = 0x04; // Profile ADC Data = ADC_In(); // sample 12-bit channel 1 PF2 = 0x00; // end of ADC Profile ST7735_SetCursor(0,0); PF1 = 0x02; // Profile LCD LCD_OutFix(Data); ST7735_OutString(" "); // these spaces are used to coverup characters from last output PF1 = 0; // end of LCD Profile } }
int main(void){ TExaS_Init(); ST7735_InitR(INITR_REDTAB); PortF_Init(); ADC_Init(); // turn on ADC, set channel to 1 SysTick_Init(); // This makes things work // your Lab 8 while(1){ while(ADCStatus == 0){} Data = ADCMail; Position = Convert(Data); ST7735_SetCursor(0,0); LCD_OutDec(Data); ST7735_OutString(" "); ST7735_SetCursor(6,0); LCD_OutFix(Position); ADCStatus = 0; } }
void mainRECEIVER(void) { unsigned char CM[5] = { ' ',' ','c','m',0, }; unsigned char *txtPnt; InData = 0; asm sei // Disable interrupts PLL_Init(); LCD_Open(); // Initializes Timer LCD_Clear(); SCI1R_Init(); DDRP |= 0x80; // PP7 output OC1_InitR(); // Intializes timer as well, receiver uses interrupt channel 1 txtPnt = CM; asm cli // Enable interrupts for(;;) { SCI1_InData(); // InData returns pnter value LCD_Clear(); LCD_OutFix(Convert(adcValue)); // Displays data in fixed point format LCD_OutString(txtPnt); Timer_wait(10); // wait 10ms } }
int main(void){ uint32_t DataTaken; uint32_t ConvData; TExaS_Init(); // Bus clock is 80 MHz PortF_Init(); ADC_Init(); // turn on ADC, set channel to 1 ST7735_InitR(INITR_REDTAB); SysTick_Init(); while(1){ if (ADCStatus == 1){ DataTaken = ADCMail; ADCStatus = 0; ConvData = Convert(DataTaken); ST7735_SetCursor(0,0); LCD_OutDec(DataTaken); ST7735_OutString(" "); ST7735_SetCursor(6,0); LCD_OutFix(ConvData); ST7735_OutString(" cm"); } } }