//***************************************************************************** // File Name : a2dtest.c // // Title : example usage of some avr library functions // Revision : 1.0 // Notes : // Target MCU : Atmel AVR series // Editor Tabs : 4 // // Revision History: // When Who Description of change // ----------- ----------- ----------------------- // 20-Oct-2002 pstang Created the program //***************************************************************************** //----- Include Files --------------------------------------------------------- #include // include I/O definitions (port names, pin names, etc) #include // include "signal" names (interrupt names) #include // include interrupt support #include "global.h" // include our global settings #include "uart.h" // include uart function library #include "rprintf.h" // include printf function library #include "timer.h" // include timer function library (timing, PWM, etc) #include "buffer.h" // include buffer function library #include "a2d.h" // include A/D converter function library #include "vt100.h" // include VT100 terminal support #define NOS 20000 // Define number of milliseconds between collects #define NOC 30 // Define number of collects (1-512) between reset //global variables unsigned int volts; // Current value of Battery Volts unsigned int shuntvolts; // Current value of Shunt Volts unsigned int pulse; // Pulses per Second unsigned int windpulse; // Windspeed Pulses per second unsigned int mode; // Dummy load on or off //function prototypes unsigned int ADCaverage (int n); //average over n samples unsigned int ADCaverage (int n){ unsigned int currentvalue = 0; // incremental value unsigned int count; // amount of samples to take for(count=0;count%d%d%d%d0]\r\n",volts,shuntvolts,pulse,windpulse); timerPause(NOS); // pause for interval between checking routine } } }