Code:
#define AVRGCC
#include <avr/io.h>
#include <util/delay.h>
#include <compiler.h>
//F_CPU = 4000000
#define BAUD 9600l
#define UBRRValue (F_CPU / (BAUD * 16) - 1)
void sendMsg (char *Msg, bool addCR)
{
while (*Msg != 0)
{
while ( !(UCSRA & (1<<UDRE)));
UDR = *Msg++;
}
if (addCR)
sendMsg ("\r\n", FALSE);
}
int main (void)
{
DDRB = 0b11111111;
PORTB = 0b00000000;
DDRD = 0b00000000;
PORTD = 0b00000000;
DDRC = 0b00000000;
PORTC = 0b00000000;
UCSRB = (1<<RXCIE) | (1<<TXEN);
UCSRC = (1<<UCSZ1) | (1<<UCSZ0);
UBRRH = (U8)(UBRRValue>>8);
UBRRL = (U8)UBRRValue;
ADMUX = (1<<REFS1) |(1<<REFS0);
ADCSRA = (1<<ADEN) | (1<<ADPS2) | (1<<ADPS1) | (1<<ADPS0);
sendMsg ("Start", TRUE);
while (1)
{
}
return (0);
}
Lesezeichen