mirror of
https://github.com/rfivet/stm32bringup.git
synced 2024-12-17 22:36:24 -05:00
Internal Temperature calculation using TS_CAL2 and reference temperature stored in User Data Option Byte.
This commit is contained in:
parent
a7cafdf989
commit
32007c1483
17
adcmain.c
17
adcmain.c
@ -6,6 +6,9 @@
|
||||
|
||||
#define RAW
|
||||
|
||||
#define TS_CAL2 ((const short *) 0x1FFFF7C2)
|
||||
#define USER0 ((const unsigned char *) 0x1FFFF804)
|
||||
|
||||
int main( void) {
|
||||
unsigned last = 0 ;
|
||||
short calV, calC ;
|
||||
@ -14,6 +17,12 @@ int main( void) {
|
||||
adc_vnt( VNT_INIT, &calV, &calC) ;
|
||||
#ifdef RAW
|
||||
printf( "%u, %u\n", calV, calC) ;
|
||||
|
||||
int baseC = 300 ;
|
||||
# ifdef USER0
|
||||
if( 0xFF == (USER0[ 0] ^ USER0[ 1]))
|
||||
baseC = USER0[ 0] * 10 ;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
for( ;;)
|
||||
@ -26,8 +35,12 @@ int main( void) {
|
||||
#ifdef RAW
|
||||
adc_vnt( VNT_RAW, &Vsample, &Csample) ;
|
||||
printf( "%i, %i, %i, %i, ", calV, Vsample, calC, Csample) ;
|
||||
Csample = 300 + (calC - (int) Csample * calV / Vsample)
|
||||
* 10000 / 5336 ;
|
||||
Csample = baseC + (calC - (int) Csample * calV / Vsample)
|
||||
# ifdef TS_CAL2
|
||||
* 800 / (calC - *TS_CAL2) ;
|
||||
# else
|
||||
* 10000 / 5336 ;
|
||||
# endif
|
||||
Vsample = 330 * calV / Vsample ;
|
||||
#else
|
||||
adc_vnt( VNT_VNC, &Vsample, &Csample) ;
|
||||
|
Loading…
Reference in New Issue
Block a user