Witam, mam problem, z odbieraniem informacji od atmegi na komputer, próbowałem różnej kombinacji prędkości i częstotliwości, ale cały czas jest to samo, pokazuje się cały czas ten sam znak. Informacje z AVRa odbieram przez program gtkterm, poniżej zamieszczam kod, na którym testuje UARTa, pochodzi on z avrfreaks
nie wiem czy to jeszcze ma znaczenie, ale układ jest podpięty pod taki konwerter RS232->USB
PS. przepraszam, jeżeli pozostawienie loga narusza regulamin, ale nie wiem czy mogę je wyciąć
#include <avr/io.h>
#include <avr/io.h>
#define USART_BAUDRATE 9600
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)
int main (void)
{
char ReceivedByte;
UCSRB |= (1 << RXEN) | (1 << TXEN); // Turn on the transmission and reception circuitry
UCSRC |= (1 << URSEL) | (1 << UCSZ0) | (1 << UCSZ1); // Use 8-bit character sizes
UBRRL = BAUD_PRESCALE; // Load lower 8-bits of the baud rate value into the low byte of the UBRR register
UBRRH = (BAUD_PRESCALE >> 8); // Load upper 8-bits of the baud rate value into the high byte of the UBRR register
while(1) // Loop forever
{
while ((UCSRA & (1 << RXC)) == 0) {}; // Do nothing until data have been recieved and is ready to be read from UDR
ReceivedByte = UDR; // Fetch the recieved byte value into the variable "ByteReceived"
while ((UCSRA & (1 << UDRE)) == 0) {}; // Do nothing until UDR is ready for more data to be written to it
UDR = ReceivedByte; // Echo back the received byte back to the computer
}
}nie wiem czy to jeszcze ma znaczenie, ale układ jest podpięty pod taki konwerter RS232->USB
PS. przepraszam, jeżeli pozostawienie loga narusza regulamin, ale nie wiem czy mogę je wyciąć