请问有没有MSP430F4793 内部温度传感器的 使用例程,十分感谢!!
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
请问有没有MSP430F4793 内部温度传感器的 使用例程,十分感谢!!
#include <msp430.h> unsigned int ADCresult; unsigned long DegC = 0; unsigned long DegF = 0; int main(void) { volatile unsigned int i; // Use volatile to prevent removal // by compiler optimization WDTCTL = WDTPW + WDTHOLD; // Stop WDT FLL_CTL0 |= XCAP11PF; // Configure load caps for (i = 0; i < 10000; i++); // Delay for 32 kHz crystal to // stabilize SD16CTL = SD16REFON+SD16SSEL0; // 1.2V ref, SMCLK SD16CCTL2 |= SD16SNGL+SD16IE ; // Single conv, enable interrupt SD16INCTL2 |= SD16INCH_6; // Select Channel A6 for (i = 0; i < 0x3600; i++); // Delay for 1.2V ref startup while (1) { SD16CCTL2 |= SD16SC; // Set bit to start conversion __bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupts DegC = ((unsigned long)ADCresult * 909)/65536 - 727; // Calculate degrees Celcius DegF = ((unsigned long)ADCresult * 1636)/65536 - 1276; // Calculate degrees Farenheit __no_operation(); //SET BREAKPOINT HERE } } #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) #pragma vector=SD16A_VECTOR __interrupt void SD16AISR(void) #elif defined(__GNUC__) void __attribute__ ((interrupt(SD16A_VECTOR))) SD16AISR (void) #else #error Compiler not supported! #endif { switch (SD16IV) { case 2: // SD16MEM Overflow break; case 4: // SD16MEM0 IFG break; case 6: // SD16MEM1 IFG break; case 8: // SD16MEM2 IFG ADCresult = SD16MEM2; // Save CH2 results (clears IFG) break; } __bic_SR_register_on_exit(LPM0_bits); // Exit LPM0 }