Demonstrates bandgap calibration and VADC sampling. VADC sampling would usually be enabled with a timed period. Here we just wait until calcualtion of VADC results are finished before calculating results and starting over again. No output is implemented, so debugging have to be used for testing.
Copyright (c) 2008, Atmel Corporation All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. The name of ATMEL may not be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Definition in file main.c.
#include "vadc_usage.h"
#include "ATmega8HVA_16HVA_signature.h"
#include <ioavr.h>
#include <inavr.h>

Go to the source code of this file.
Functions | |
| void | main (void) |
| void main | ( | void | ) |
Definition at line 61 of file main.c.
References CalculateADCResults(), CALIB_HOT, CALIB_ROOM, CalibrateVREF(), InitBandgap(), InitCoeff(), StartVADCScan(), and vadc_scan_complete.
00062 { 00063 uint8_t status; 00064 00065 // Load coefficients needed for calcualations from the signature row. 00066 InitCoeff(); 00067 00068 /* Initialize band-gap reference to factory calibration. Calibration might 00069 * either have been done only at a HOT temperature, or also at room 00070 * temperature for complete calibration. Loading of HOT calibration _must_ 00071 * be done before running CalibrateVREF() function. 00072 */ 00073 status = InitBandgap(); 00074 00075 // Check if calibration was only done at HOT temperaure. 00076 if( status == CALIB_HOT ){ 00077 if(CalibrateVREF()){ 00078 // Eternal loop if calibration failed. 00079 do {} while (1); 00080 } 00081 }else{ 00082 // Check if calibration was also done at room temperature. 00083 if(status != CALIB_ROOM){ 00084 // Eternal loop if device was not calibrated at all. 00085 do {} while (1); 00086 } 00087 } 00088 00089 /* Voltage ADC measurements and calculations. Results are stored in global 00090 * variables; \ref cell_v[NO_CELLS], adc and \ref bg_temp. 00091 */ 00092 do { 00093 StartVADCScan(); 00094 do{} while (!vadc_scan_complete); 00095 CalculateADCResults(); 00096 } while(1); 00097 }

1.5.5