- #1
TheRedDevil18
- 408
- 1
I am using proteus to simulate an atmega32. I load the code but I don't think the interrupt is firing
Circuit:
Once the interrupt fires it should send 'A' continuously to USART.
Code:
#include <avr/io.h>
#include <avr/interrupt.h>
#ifndef F_CPU
#define F_CPU 8000000UL
#endif
#define BAUD 9600 // define baud
#define BAUDRATE ((F_CPU)/(BAUD*16UL)-1)void adcInitialize();
void USARTInitialize();int main(void)
{
sei();
USARTInitialize();
adcInitialize();
while(1)
{
}
}
ISR(ADC_vect)
{
char letter = 'A';
while (1)
{
while (!( UCSRA & (1<<UDRE)));
{
}
UDR = letter;
}
ADCSRA = (1<<ADIF); //Clear interrupt flag
ADCSRA = (1<<ADSC); //Start conversion
}
void adcInitialize()
{
DDRA = 0x00;
ADMUX = (1<<REFS0); //Vcc
ADCSRA = (1<<ADEN)|(1<<ADIE)|(1<<ADPS0)|(1<<ADPS1)|(1<<ADPS2);
ADCSRA = (1<<ADSC); //Start ADC conversion
}
void USARTInitialize()
{
UBRRL = BAUDRATE; //Set baud rate
UCSRB = (1<<TXEN); // Enable transmitter
UCSRC = (1<<URSEL)|(1<<UCSZ0)|(1<<UCSZ1); //8 bit data
}
Circuit:
Once the interrupt fires it should send 'A' continuously to USART.