|
From: | mickhail mcanuff |
Subject: | [avr-gcc-list] Help Needed (UART / USART) |
Date: | Sun, 18 Mar 2007 15:29:57 -0400 |
return 0;
}
#include <stdint.h>
#define F_CPU 3686400UL
#include <avr/io.h>
// Define baud rate
#define UART_BAUD 2400ul
#define UART_UBBR_VALUE ((F_CPU/(UART_BAUD<<4))-1)
void UART_vInit(void)
{
// Set baud rate
UBRRH = (uint8_t)(USART_UBBR_VALUE>>8);
UBRR = (uint8_t)UART_UBBR_VALUE;
// Set frame format to 8 data bits, no parity, 1 stop bit
//UCR = (0<<USBS)|(1<<UCSZ1)|(1<<UCSZ0);
// Enable receiver
UCR = (1<<RXEN);
}
uint8_t UART_vReceiveByte()
{
// Wait until a byte has been received
while((UCR&(1<<RXC)) == 0);
// Return received data
return UDR;
}
int main(void)
{
uint8_t u8Data;
// Initialise USART
UART_vInit();
// Repeat indefinitely
while (1)
{
//received characters
u8Data = UART_vReceiveByte();
switch(u8Data)
{
case '0' = PORTB = 0x00;
break;
case '1' = PORTB = 0x01;
break;
//........ continues to '9'
case '9' = PORTB = 0xA1;
break;
}
}
}
The purpose of this code is to receive the data sent from the 2313 and turn on 7 segment display located on PORTB. The code doesnt seem to be receiving. I wonder if the ATmega8515 can communicate with the AT90s2313?? Help pleeeeeze!!!!!!!!!!!!
[Prev in Thread] | Current Thread | [Next in Thread] |