You need to log in to create posts and topics.

AVR USART 7-bit mode doesn't work

Hi,

I'm trying to establish communication between PC and ATmega328 but I found that in 7 bit mode AVR is still sending 8 bits.

Here is my test code (what comes from the serial line should be returned immediately):

#include <avr/io.h>

int main(void)
{
    UBRR0   = 103;              // 9600 bps
    UCSR0B |= (1 << RXEN0);
    UCSR0B |= (1 << TXEN0);
    UCSR0C |= (3 << UCSZ00);    // 8-bit mode
//    UCSR0C |= (1 << UCSZ01);	    // 7-bit mode

    uint8_t data;

    while (1) {
        while (!(UCSR0A & (1 << RXC0)));
        data = UDR0;
        while (!(UCSR0A & (1 << UDRE0)));
        UDR0 = data;
    }
}

Can you take a look at it?

Thank you.

Thanks for reporting, I will have a look.

 

Problem solved.

Keep an eye on tester builds for next update:
https://simulide.com/p/testers/