Note that there are some explanatory texts on larger screens.

plurals
  1. POAVR Butterfly UART - can't receive data
    text
    copied!<p>I am using the UART of Atmega169/AVR Butterfly for transmission to another board, baudrate 56700, no parity, 1 stopbit, no flow control. The oscillator is running at 7,3768Mhz (checked). I can transmit data successfully (checked with the other board and PC/HyperTerminal), but not receive any data - when running the debugger the configuration bits are all set correctly, but RXC is false constantly - I also checked if I can send data to myself (connected TXD to RXD and grounded), but without success. (Tried with ISR as well as polling) Below are the relevant parts of the code, I hope you can deal with it - PORTB is used as output for testing with the oscilloscope (I know I could just use one pin, but there is nothing else on PORTB right now):</p> <pre><code>int main(void){ OSCCAL_Calibrate(); // calibrate the internal oscillator int UBRR_VAL = ((F_CPU)/(BAUD*16)-1); UART_Init(UBRR_VAL); DDRB |= 0xFF; PORTB = 0; testCharSend(); while(1); return 0; } void testCharSend() { char i = 'x'; while(1){ Uart_Tx(i); } } void UART_Init(unsigned int baudrate) { // Set baud rate UBRRH = (unsigned char)(baudrate&gt;&gt;8); UBRRL = (unsigned char)baudrate; UCSRA = 0; // Enable receiver and transmitter UCSRB = (1&lt;&lt;RXEN)|(1&lt;&lt;TXEN); // Async. mode, 8bit, No parity, 1 stop bit (like CC2540) UCSRC = (0&lt;&lt;UMSEL)|(0&lt;&lt;UPM0)|(0&lt;&lt;USBS)|(3&lt;&lt;UCSZ0)|(0&lt;&lt;UCPOL); // enable receive interrupt UCSRB |= (1&lt;&lt;RXCIE); // flush UART UART_Flush(); } void UART_Flush( void ) { unsigned char dummy; while ( UCSRA &amp; (1&lt;&lt;RXC) ) dummy = UDR; } void Uart_Tx(char data) { while (!(UCSRA &amp; (1&lt;&lt;UDRE))); UDR = data; } ISR (USART0_RX_vect) { PORTB ^= 0xFF; char c = UDR; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload