Jan Waclawek
/
STM32L0_TempSensor
fork
Fork of STM32L0_TempSensor by
Revision 1:d208073b902e, committed 2017-02-23
- Comitter:
- wek
- Date:
- Thu Feb 23 01:46:57 2017 +0000
- Parent:
- 0:7adc363a814e
- Commit message:
- a
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 7adc363a814e -r d208073b902e main.cpp --- a/main.cpp Wed Feb 22 13:51:52 2017 +0000 +++ b/main.cpp Thu Feb 23 01:46:57 2017 +0000 @@ -10,10 +10,15 @@ int32_t ComputeTemperature(uint32_t measure) { int32_t temperature; + pcMain.printf("TEMP130=%u TEMP30=%u\n", *TEMP130_CAL_ADDR, *TEMP30_CAL_ADDR); temperature = ((measure * VDD_APPLI / VDD_CALIB) - (int32_t)*TEMP30_CAL_ADDR ); + pcMain.printf("T1 %d\n", temperature); temperature = temperature *(int32_t)(130-30); - temperature = temperature /(int32_t)(*TEMP130_CAL_ADDR -*TEMP30_CAL_ADDR); + pcMain.printf("T2 %d\n", temperature); + temperature = temperature /(int32_t)(*TEMP130_CAL_ADDR - *TEMP30_CAL_ADDR); + pcMain.printf("T3 %d\n", temperature); temperature = temperature + 30; + pcMain.printf("T4 %d\n", temperature); return(temperature); } @@ -32,7 +37,7 @@ ADC1->CR |= ADC_CR_ADCAL; /* (3) */ while ((ADC1->ISR & ADC_ISR_EOCAL) == 0) /* (4) */ { - pcMain.printf("Calib"); + pcMain.printf("Calib\n"); } ADC1->ISR |= ADC_ISR_EOCAL; @@ -43,7 +48,7 @@ { while ((ADC1->ISR & ADC_ISR_ADRDY) == 0) /* (3) */ { - pcMain.printf("Enable"); + pcMain.printf("Enable\n"); } } //*******************//NEW PART END//******************// @@ -52,12 +57,16 @@ ADC1->CFGR1 |= ADC_CFGR1_CONT; /* (2) */ ADC1->CHSELR = ADC_CHSELR_CHSEL18; /* (3) */ ADC1->SMPR |= ADC_SMPR_SMP; /* (4) */ - wait(1); + wait_ms(10); ADC->CCR |= ADC_CCR_TSEN; - wait(1); + ADC1->CR |= ADC_CR_ADSTART; /* start the ADC conversion */ + wait_ms(10); + while(1) { + wait_ms(300); uint32_t measure = ADC1->DR; - pcMain.printf("Measure %u\n\r", measure); - pcMain.printf("The temperature value is %i\n\r",ComputeTemperature(measure)); + pcMain.printf("Measure %u\n", measure); + pcMain.printf("The temperature value is %i\n",ComputeTemperature(measure)); + } }