Witam
Atmega128, podłączony rs przez max323, elektrycznie dziala ok.
Niestety nie mogę go uruchomić poprawnie.
deklaracja:
Cytuj:
#define F_CPU 16000000 <--- proszę tego nigdy nie wpisywać w kodzie a szczególnie na tym forum - mirekk36
Kod:
#define USART_BAUDRATE 9600
#define BAUDVALUE ((F_CPU/(USART_BAUDRATE * 16UL)) - 1 )
Ustawiam fuse:
Kod:
void uart_init(){
UCSR0B |= (1<<RXEN0) | (1<<TXEN0) | (1<<RXCIE0);; // Turn on the transmission and reception circuitry
UCSR0C |= (1<<UCSZ01) | (1<<UCSZ00); // Use 8- bit character sizes - URSEL bit set to select the UCRSC register
UBRR0H = ( BAUDVALUE >> 8);// Load upper 8- bits of the baud rate value into the high byte of the UBRR register
UBRR0L = BAUDVALUE ; // Load lower 8- bits of the baud rate value into the low byte of the UBRR register
funkcja wysylania:
Kod:
void uart_puts(char *str) {
int i = 0;
while(str[i] != '\0') { // Loop through string, sending each character
uart_putc(str[i]);
i++;
}
}
Wysylam:
uart_puts("wrote test: ");
a dostaje na terminalu
"óŔ‡ĘŔđŔ4řň<0>őŔń34J @ŔpŔ€Â±Ä4 ÉEúEŔőŔń3JŔpŔ€Ŕ°Ŕ4ÍEţEŔôŔń34J @ŔpŔ€Â±Ä4 ËEüEŔôŔń3JŔpŔ€Ŕ°Ŕ4ĎEřIŔ"
Czyli same smieci.
Gdzie robie blad?