Skip to content
Snippets Groups Projects
Commit 86e40598 authored by Leonardo Martinez Hornak's avatar Leonardo Martinez Hornak
Browse files

Temperature obtained in celsius degrees

parent 43eeac23
No related branches found
No related tags found
No related merge requests found
......@@ -37,8 +37,8 @@ void setTempCallbackFunction(void *callback_function);
void runADCConversion(void);
/**
* @brief Obtains the last temperature reading in milicelsius
* @return int temperature in celsius degrees divided by 1000
* @brief Obtains the last temperature reading in celsius
* @return int temperature in celsius degrees
*
*/
int getTemperatureReading(void);
......
......@@ -12,5 +12,6 @@
#define INCLUDE_COMMON_H_
//#define DEBUG
#define REF_VOLTAGE_DIV_BY_ADC_10BITS_RESOLUTION 1.17
#endif /* INCLUDE_COMMON_H_ */
#include <msp.h>
#include "common.h"
#include "adc.h"
#include "fifo_function_queue.h"
......@@ -55,25 +56,28 @@ void runADCConversion(){
int getTemperatureReading(){
int temp;
//Converts mVolts to miliCelsius using temperature sensor transfer function (no calibration)
float aux;
//Converts ADC Reading to mVolts (1.2 Volts set for reference voltage)
aux = (float)(adcval) * REF_VOLTAGE_DIV_BY_ADC_10BITS_RESOLUTION;
//Converts mVolts to celsius using temperature sensor transfer function (no calibration)
//Using 10 bits resolution
temp = (((adcval - 686) * 512)/1024);
temp = (int)((aux - 686) * 0.512);
return temp;
}
void ADC14_IRQHandler(void)
{
addToFunctionQueue(temperature_ready_callback);
//Reading to ADC14MEM clears the IFG
adcval = ADC14->MEM[0];
ADC14->CTL0 &= ~ADC14_CTL0_ENC;
ADC14->CTL0 &= ~ADC14_CTL0_ON;
__low_power_mode_off_on_exit();
//Disable ISRs
ADC14 -> IER0 &= ~ADC14_IER0_IE0;
NVIC_DisableIRQ(ADC14_IRQn);
addToFunctionQueue(temperature_ready_callback);
__low_power_mode_off_on_exit();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment