Witam. Mam problem z transmisją do kompa. Przeglądałem forum ale nie moge znaleść odpowiedzi na moje pytanie. Atmega ma wysyłać po rs do kompa znaki ale nic w teminalu sie nie pojawia. Mam ustawioną predkość transmisji na 19200. Kwarc 12MHz.
kod wygląda tak:
Może mam coś źle napisane, a jestem troche zielony w tym temacie. Inicjalizacjjie wziąłem z datasheet.
kod wygląda tak:
#include <inttypes.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <string.h>
#define F_CPU 12000000UL
/*UART*/
void USART_Transmit_String(char *tekst);
void USART_Init( unsigned int baud );
void USART_Transmit( unsigned char data );
unsigned char USART_Receive( void );
int main(void)
{
USART_Init(38);
while(1)
{
USART_Transmit('a');
USART_Transmit(13);
}
}
void USART_Init( unsigned int baud )
{
UBRRH = (unsigned char)(baud>>8); /* Set baud rate */
UBRRL = (unsigned char)baud;
UCSRB = (1<<RXEN)|(1<<TXEN); /* Enable Receiver and Transmitter */
UCSRC = (1<<URSEL)|(1<<USBS)|(3<<UCSZ0); /* Set frame format: 8data, 2stop bit */
}
void USART_Transmit( unsigned char data )
{
while ( !( UCSRA & (1<<UDRE)) ); /* Wait for empty transmit buffer */
UDR = data; /* Put data into buffer, sends the data */
}
unsigned char USART_Receive( void )
{
while ( !(UCSRA & (1<<RXC)) ); /* Wait for data to be received */
return UDR; /* Get and return received data from buffer */
}Może mam coś źle napisane, a jestem troche zielony w tym temacie. Inicjalizacjjie wziąłem z datasheet.
