[an error occurred while processing this directive]
|
/* adc8535.c
ADC example for the AT90S8535 on
the Atmel STK500 starter kit
CodeVisionAVR C Compiler
© Copyright 2001-2002 HP InfoTech S.R.L.
www.hpinfotech.ro
Set the following jumpers on the STK500 board:
VTARGET, AREF, RESET, XTAL1, OSCSEL: 1-2
Connect the PORTB and LEDS headers with
a 10 wire ribbon cable
Connect the ISP6PIN and SPROG3 headers with
a 6 wire ribbon cable
The AT90S8535 must be located on socket SCKT3100A3
In the AVR Studio Tools|STK500|Board window set:
- VTarget=5.0V
- ARef=5.0V
- Oscillator=3.69MHz
Apply a positive DC voltage in the 0..5.0V range
between the PORTA header PA0 and GND pins
*/
// I/O register definitions for AT90S8535 #define ADC_VREF_TYPE 0x00 void main(void) // ADC initialization // Global enable interrupts // Select ADC input 0 // Start the first AD conversion // All the job is done by ADC interrupts
E-mail:
info@telesys.ru
#include <90s8535.h>
// delay functions
#include
// ADC interrupt service routine
interrupt [ADC_INT] void adc_isr(void)
{
// The LEDs will display the 8 most
// semnificative ADC bits
PORTB=(unsigned char) ~(ADCW>>2);
// 20ms delay
delay_ms(20);
// Start a new AD conversion
ADCSR|=0x40;
}
{
// Port B initialization
PORTB=0xFF; // all outputs
DDRB=0xFF; // all LEDs are initially off
// ADC Clock frequency: 57.656 kHz
// ADC Interrupts: On
ADCSR=0x8E;
#asm("sei")
ADMUX=0;
ADCSR|=0x40;
while (1);
}
Ответы