Functions

ADC Low Level Fucntions
[Temperature Sensor]

Temperature Sensor Functions. More...

Functions

void get_cal_values (void)
 Read OSC Calibration Values.
void calibrate_inter_osc (enum vcc v)
 Calibrate the internal OSC.
S16 read_temp_sensor (void)
 Read and return temperature from internal temperature sensor.
U16 get_temp_sensor_val (void)
 Read and return internal temperature sensor ADC channel.

Detailed Description

Temperature Sensor Functions.


Function Documentation

void get_cal_values ( void   )

Read OSC Calibration Values.

Read OSC Calibration Values.

Parameters:

Definition at line 77 of file cal_inter_rc.c.

References flash_read_sig(), n_step, offset, osc_cal_25_3v, osc_cal_25_5v, osc_cal_85_3v, period, temp_sensor_25, and temp_sensor_85.

Referenced by calibrate_inter_osc().

{
  U8 temp_sensor_25_lo;
  U8 temp_sensor_25_hi;
  U8 temp_sensor_85_lo;
  U8 temp_sensor_85_hi;
  osc_cal_25_3v = flash_read_sig(0x01);
  osc_cal_85_3v = flash_read_sig(0x03);
  osc_cal_25_5v = flash_read_sig(0x05);
  temp_sensor_25_lo = flash_read_sig(0x38);
  temp_sensor_25_hi = flash_read_sig(0x39);
  temp_sensor_85_lo = flash_read_sig(0x3A);
  temp_sensor_85_hi = flash_read_sig(0x3B);
  temp_sensor_25 = (temp_sensor_25_hi << 8) + temp_sensor_25_lo;
  temp_sensor_85 = (temp_sensor_85_hi << 8) + temp_sensor_85_lo;
  offset = (osc_cal_25_5v) - (osc_cal_25_3v);
  n_step = osc_cal_25_3v - osc_cal_85_3v;
  period = (temp_sensor_85 - temp_sensor_25)/n_step;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void calibrate_inter_osc ( enum vcc  v )

Calibrate the internal OSC.

Calibrate the internal OSC.

Parameters:
enumvcc: vcc_5 or vcc_3

Definition at line 101 of file cal_inter_rc.c.

References get_cal_values(), get_temp_sensor_val(), offset, osc_cal_25_3v, osc_cal_85_3v, period, temp_sensor_25, temp_sensor_85, temp_value, and vcc_3.

Referenced by main(), and update_osc_cal_task().

{
  U8 osc_cal;
  get_cal_values();
  osc_cal = osc_cal_25_3v;
  temp_value = get_temp_sensor_val();

   if(temp_value < temp_sensor_25)
   {
     for (U16 t = temp_sensor_25; t>0; t-=period)
        {
          osc_cal++;
          if(t<temp_value)
            break;
        }
   }
     else if(temp_value >= temp_sensor_85)
     osc_cal = osc_cal_85_3v;
      else if(temp_value > temp_sensor_25)
      { for (U16 t = temp_sensor_25; t<temp_sensor_85; t+=(2*period))
        {
          osc_cal--;
          if(t>temp_value)
            break;
        }
      }
  if(vcc_3)
  {
   OSCCAL = osc_cal;
  }
 else OSCCAL = osc_cal + offset;

}

Here is the call graph for this function:

Here is the caller graph for this function:

S16 read_temp_sensor ( void   )

Read and return temperature from internal temperature sensor.

Definition at line 63 of file temp_sensor.c.

References get_temp_sensor_val().

{
   get_temp_sensor_val();
   #warning TODO....
   return 1;

}

Here is the call graph for this function:

U16 get_temp_sensor_val ( void   )

Read and return internal temperature sensor ADC channel.

Definition at line 72 of file temp_sensor.c.

References ADC_TEMP_SENSOR_CHANNEL, Is_adc_conv_finished, and Start_conv_channel.

Referenced by calibrate_inter_osc(), and read_temp_sensor().

{
   Start_conv_channel(ADC_TEMP_SENSOR_CHANNEL);
   while (!Is_adc_conv_finished());
   return (U16)(ADCL+((U16)(ADCH<<8)));
}

Here is the caller graph for this function: