Other Parts Discussed in Thread: TMP236, LDC1612
Tool/software: Code Composer Studio
Hello guys,
We are developing a system based on the LDC1612EVM board, however we have a Temperatur Sensor on PIN A7.
My Code is based on the sample Code for the LDC1612EVM Board. I have a UART Communication with the Host PC which I have modified to communicate directly with 3rd Party Com Tools.
My Problem is reading the ADC values. Below my Code for reading the ADC.
initTemp will be executed in main, but not in the Loop.
When starting a Stream to get LDC Values the TempLoop get executed, LDC values are pulled from the LDC and then getTemp is executed.
Doing it this way i get unstable values from the ADC. In Temperature Scale a difference from 9°C. I am using the TMP236 as Tempsensor.
When I using the interrupt from the ADC my UART Communication doesn't work.
What can I do to improve the accuracy of my Temp sensor?
Best regards
volatile temp Temperatur; volatile uint8_t trigger = 0; #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) #pragma vector=ADC12_VECTOR __interrupt void ADC12ISR (void) #elif defined(__GNUC__) void __attribute__ ((interrupt(ADC12_VECTOR))) ADC12ISR (void) #else #error Compiler not supported! #endif { switch(__even_in_range(ADC12IV,34)) { case 0: break; // Vector 0: No interrupt case 2: break; // Vector 2: ADC overflow case 4: break; // Vector 4: ADC timing overflow case 6: break; // Vector 6: ADC12IFG0 case 8: break; // Vector 8: ADC12IFG1 case 10: break; // Vector 10: ADC12IFG2 case 12: // Vector 12: ADC12IFG3 __bic_SR_register_on_exit(LPM4_bits); // Exit active CPU, SET BREAKPOINT HERE break; case 14: break; // Vector 14: ADC12IFG4 case 16: break; // Vector 16: ADC12IFG5 case 18: break; // Vector 18: ADC12IFG6 case 20: break; // Vector 20: ADC12IFG7 case 22: break; // Vector 22: ADC12IFG8 case 24: break; // Vector 24: ADC12IFG9 case 26: break; // Vector 26: ADC12IFG10 case 28: break; // Vector 28: ADC12IFG11 case 30: break; // Vector 30: ADC12IFG12 case 32: break; // Vector 32: ADC12IFG13 case 34: break; // Vector 34: ADC12IFG14 default: break; } } void initTemp(){ P6SEL = TEMP_PIN; // Enable A/D channel A7 REFCTL0 &= ~REFMSTR; ADC12CTL0 = ADC12ON+ADC12SHT0_8+ADC12REFON; // Turn on ADC12, extend sampling time ADC12CTL1 = ADC12SHP; // Use sampling timer ADC12IE = 0x08; __delay_cycles(100); ADC12CTL0 |= ADC12ENC; } void TempLoop(){ ADC12CTL0 |= ADC12SC; //__bis_SR_register(LPM4_bits + GIE); // Enter LPM4, Enable interrupts //__no_operation(); } temp getTemp() { Temperatur.raw = ADC12MEM0; float test = (((float)Temperatur.raw * (1.5f/4096)) - 0.4f)/0.019f; Temperatur.num1 = test; Temperatur.num2 = ((test - Temperatur.num1) >= 0.5f) ? 5 : 0; return Temperatur; }