Added NTC_MCU_TEMP and NTC_TEC_TEMP measurement
This commit is contained in:
parent
8c00c02a3a
commit
79f64d47ab
Binary file not shown.
|
|
@ -10,18 +10,18 @@
|
|||
#define NTC_H_
|
||||
#include <asf.h>
|
||||
#include "adc_user.h"
|
||||
// ADC value to R
|
||||
float NTC_MCU_value2R(uint16_t value);
|
||||
// ADC value to R
|
||||
float NTC_MCU_value2R(uint16_t value);
|
||||
|
||||
float NTC_TEC_value2R(uint16_t value);
|
||||
float NTC_TEC_value2R(uint16_t value);
|
||||
|
||||
// Resistance to Temp
|
||||
float NTC_R2T(float R);
|
||||
// Resistance to Temp
|
||||
float NTC_R2T(float R);
|
||||
|
||||
// Read ADC and calculate temperature in Cenlsius.
|
||||
float NTC_MCU_get_temp(uint16_t *p_adc_val);
|
||||
// Read ADC and calculate temperature in Cenlsius.
|
||||
float NTC_MCU_get_temp(uint16_t *p_adc_val);
|
||||
|
||||
float NTC_TEC_get_temp(uint16_t *p_value, float *p_R);
|
||||
float NTC_TEC_get_temp(uint16_t *p_value, float *p_R);
|
||||
|
||||
|
||||
#endif /* NTC_H_ */
|
||||
|
|
@ -78,7 +78,7 @@ int main(void)
|
|||
InitTask_cdc_rx_check();
|
||||
// Init LED
|
||||
InitTask_led_blink();//ui_init();//ui_powerdown();
|
||||
InitTask_mesure();
|
||||
InitTask_measure();
|
||||
vTaskStartScheduler();
|
||||
while(true){
|
||||
__BKPT();
|
||||
|
|
@ -174,18 +174,19 @@ void Task_led_blink(void *parameters)
|
|||
}
|
||||
}
|
||||
|
||||
void Task_mesure(void *parameters)
|
||||
void Task_measure(void *parameters)
|
||||
{
|
||||
uxHighWaterMark_mesure = uxTaskGetStackHighWaterMark( NULL );
|
||||
for (;;)
|
||||
{
|
||||
Controller.temps.MCU_Temp = NTC_MCU_get_temp(NULL);
|
||||
Controller.temps.TEC_Temp = NTC_TEC_get_temp(NULL, NULL);
|
||||
if (main_b_cdc_enable && udi_cdc_multi_is_tx_ready(PORT0))
|
||||
{
|
||||
if(fpclassify(Controller.temps.MCU_Temp) == FP_NAN)
|
||||
printf(">NTC_TEMP = NAN\n\r");
|
||||
if(fpclassify(Controller.temps.MCU_Temp) == FP_NAN)
|
||||
printf(">NTC_MCU_TEMP = NAN\n\r");
|
||||
else
|
||||
printf(">NTC_TEMP = %d\n\r", (int)Controller.temps.MCU_Temp );
|
||||
printf(">NTC_MCU_TEMP = %d, NTC_TEC_TEMP = %d\n\r", (int)Controller.temps.MCU_Temp, (int)Controller.temps.TEC_Temp);
|
||||
}
|
||||
LED_Toggle(LED_PIN);
|
||||
uxHighWaterMark_mesure = uxTaskGetStackHighWaterMark( NULL );
|
||||
|
|
@ -200,10 +201,10 @@ void InitTask_led_blink(void)
|
|||
//xTaskCreate(Task_led_blink, (const char*)"Task_led_blink", configMINIMAL_STACK_SIZE*2, NULL,configMAX_PRIORITIES-1, NULL);
|
||||
}
|
||||
|
||||
void InitTask_mesure(void)
|
||||
void InitTask_measure(void)
|
||||
{
|
||||
configure_adc();
|
||||
xTaskCreate(Task_mesure, (const char*)"Task_mesure", configMINIMAL_STACK_SIZE*2, NULL,configMAX_PRIORITIES-1, NULL);
|
||||
xTaskCreate(Task_measure, (const char*)"Task_measure", configMINIMAL_STACK_SIZE*2, NULL,configMAX_PRIORITIES-1, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -71,12 +71,12 @@ void vApplicationMallocFailedHook (void);
|
|||
void vApplicationStackOverflowHook (void);
|
||||
void Task_cdc_rx_check(void *parameters);
|
||||
void Task_led_blink(void *parameters);
|
||||
void Task_mesure(void *parameters);
|
||||
void Task_measure(void *parameters);
|
||||
void Task_regulator(void *parameters);
|
||||
void InitTask_cdc_rx_check(void);
|
||||
void InitTask_led_blink(void);
|
||||
void InitTask_regulator(void);
|
||||
void InitTask_mesure(void);
|
||||
void InitTask_measure(void);
|
||||
|
||||
/*! \brief Opens the communication port
|
||||
* This is called by CDC interface when USB Host enable it.
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ void configure_adc(void)
|
|||
config_adc.reference = ADC_REFERENCE_INTVCC0;
|
||||
|
||||
config_adc.resolution = ADC_RESOLUTION_12BIT;
|
||||
config_adc.gain_factor = ADC_GAIN_FACTOR_1X;
|
||||
config_adc.freerunning = true;
|
||||
//config_adc.gain_factor = ADC_GAIN_FACTOR_1X;
|
||||
//config_adc.freerunning = true;
|
||||
config_adc.correction.correction_enable = true;
|
||||
config_adc.correction.offset_correction = -16;//ADC_OFFSETCORR_OFFSETCORR(offsetCorr.reg);//
|
||||
config_adc.correction.gain_correction = (1<<11);//1.0ADC_GAINCORR_GAINCORR(gainCorr.reg);//
|
||||
|
|
@ -36,23 +36,22 @@ void configure_adc(void)
|
|||
adc_init(&adc_instance, ADC, &config_adc);
|
||||
|
||||
adc_enable(&adc_instance);
|
||||
adc_start_conversion(&adc_instance);
|
||||
//adc_start_conversion(&adc_instance);
|
||||
}
|
||||
|
||||
uint16_t adc_read_value(void)
|
||||
/*uint16_t adc_read_value(void)
|
||||
{
|
||||
uint16_t result = 0xFFFF;
|
||||
adc_read(&adc_instance, &result);
|
||||
return result;
|
||||
}
|
||||
/*uint16_t adc_read_value(void){
|
||||
}*/
|
||||
uint16_t adc_read_value(void){
|
||||
adc_start_conversion(&adc_instance);
|
||||
uint16_t result;
|
||||
do {
|
||||
|
||||
do {
|
||||
} while (adc_read(&adc_instance, &result) == STATUS_BUSY);
|
||||
return result;
|
||||
}*/
|
||||
}
|
||||
|
||||
uint16_t adc_read_value_spec(ADC_chan_t chan)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue