int main(void){ Output_Init(); // ST7735_XYplotInit("Temp", 0, 100, 0, 100); PLL_Init(Bus80MHz); // 80 MHz SYSCTL_RCGCGPIO_R |= 0x20; // activate port F ADC0_InitSWTriggerSeq3_Ch9(); // allow time to finish activating Timer0A_Init100HzInt(); // set up Timer0A for 100 Hz interrupts GPIO_PORTF_DIR_R |= 0x06; // make PF2, PF1 out (built-in LED) GPIO_PORTF_AFSEL_R &= ~0x06; // disable alt funct on PF2, PF1 GPIO_PORTF_DEN_R |= 0x06; // enable digital I/O on PF2, PF1 // configure PF2 as GPIO GPIO_PORTF_PCTL_R = (GPIO_PORTF_PCTL_R&0xFFFFF00F)+0x00000000; GPIO_PORTF_AMSEL_R = 0; // disable analog functionality on PF PF2 = 0; // turn off LED EnableInterrupts(); ST7735_SetCursor(6,0); printf("C"); ST7735_SetCursor(13,0); printf("ADC"); while(1){ PF1 ^= 0x02; // toggles when running in main temperature = adcToTemp(ADCvalue); ST7735_SetCursor(0,0); ST7735_sDecOut2(temperature); ST7735_SetCursor(9,0); ST7735_OutUDec(ADCvalue); } }
//debug code int main(void){ PLL_Init(Bus80MHz); // bus clock at 50 MHz Output_Init(); SYSCTL_RCGCGPIO_R |= 0x20; // activate port F //ADC0_InitTimer0ATriggerSeq3(2, F30HZ); // ADC channel 0, 1000 Hz sampling ADC0_InitTimer0ATriggerSeq3PD3(F30HZ); //ADC0_InitSWTriggerSeq3_Ch9(); while((SYSCTL_PRGPIO_R&0x0020) == 0){};// ready? GPIO_PORTF_DIR_R |= 0x02; // make PF1 output (PF1 built-in LEDs) GPIO_PORTF_AFSEL_R &= ~0x02; // disable alt funct on PF1 GPIO_PORTF_DEN_R |= 0x02; // enable digital I/O on PF1 // configure PF1 as GPIO GPIO_PORTF_PCTL_R = (GPIO_PORTF_PCTL_R&0xFFFFF0FF)+0x00000000; GPIO_PORTF_AMSEL_R = 0; // disable analog functionality on PF EnableInterrupts(); plotInit(); while(1){ GPIO_PORTF_DATA_R ^= 0x02; // toggle LED //ADCvalue = ADC0_InSeq3(); temperature = adcToTemp(ADCvalue + offset); plotPoint(); ST7735_SetCursor(1,2); ST7735_sDecOut2(temperature); ST7735_SetCursor(2,1); ST7735_OutUDec(ADCvalue + offset); } }
void plotInit(void){ ST7735_SetCursor(0,0); ST7735_OutString("Temp"); ST7735_PlotClear(1000,4000); // range from 0 to 4095 ST7735_SetCursor(0,1); ST7735_OutString("N="); ST7735_SetCursor(0,2); ST7735_OutString("T="); ST7735_sDecOut2(0000); ST7735_SetCursor(7,2); ST7735_OutString("C"); }
void ST7735_InitTemperatureGraph() { ST7735_SetCursor(0,0); ST7735_OutString("Temperature Data"); ST7735_PlotClear(1000,4000); // range from 0 to 4095 ST7735_SetCursor(0,1); ST7735_OutString("N="); ST7735_SetCursor(0,2); ST7735_OutString("T= "); ST7735_sDecOut2(2500); ST7735_OutString(" C"); }
void ST7735_UpdateTemperatureGraph(uint32_t numSamples, uint16_t adcValue) { uint16_t temperature = getTemp(adcValue); // DEBUG // Magnify the plot to see the noise distribution better // ST7735_PlotPoint((temperature - 2200)*15); ST7735_PlotPoint(temperature); // Measured temperature if((numSamples&(N-1))==0){ // fs sampling, fs/N samples plotted per second ST7735_PlotNextErase(); // overwrites N points on same line } if((numSamples%FS)==0){ // fs sampling, 1 Hz display of numerical data ST7735_SetCursor(3,1); ST7735_OutUDec(adcValue); // 0 to 4095 ST7735_OutString(" "); // clear previous number ST7735_SetCursor(3,2); ST7735_sDecOut2(temperature); // 0.01 C } }