[an error occurred while processing this directive]
|
передача в чистом виде работает нормально, что зашито в МК то и принимается на компьютер, программа в виде эхо отсылает обратно в компьютер не тот символ что вводишь с клавиатуры?
За образец был взят пример AVR306
Где может быть косяк?
МЕГА32, кварц 8 МГц
// AVR306: Using the AVR UART in C
// Routines for polled USART// Includes
#include
#include// Prototypes
void USART_Init( unsigned int baudrate );
unsigned char USART_Receive( void );
void USART_Transmit( unsigned char data );// Initialize UART
void USART_Init( unsigned int baudrate )
{
// Set the baud rate
UBRRH = (unsigned char) (baudrate>>8);
UBRRL = (unsigned char) baudrate;
// Enable UART receiver and transmitter
UCSRB = ( ( 1 << RXEN ) | ( 1 << TXEN ) );
// Set frame format: 8 data 2stop parity
//UCSRC = (1<UCSRC = (1<
}// Read and write functions
unsigned char USART_Receive( void )
{
PORTD &= ~BIT(PORTD7); // сигнал на прием через MAX3443E
NOP();
// Wait for incomming data
while ( !(UCSRA & (1<;
// Return the data
return UDR;
}void USART_Transmit( unsigned char data )
{
// Wait for empty transmit buffer
PORTD |= BIT(PORTD7); // порт управл дрйвером MAX3443E
NOP();
while ( !(UCSRA & (1<;
// Start transmittion
UDR = data;
}// Main - a simple test program
void main( void )
{
int x;
DDRD |= BIT(7);
USART_Init( 51 ); // Set the baudrate to 9600 bps using a 8MHz crystalwhile(1)
{
USART_Transmit( USART_Receive() ); // Echo the received character
}
}