cwalter-at / freemodbus

BSD licensed MODBUS RTU/ASCII and TCP slave
720 stars 379 forks source link

Wrong bit name in AVR Example #36

Open zerberus666 opened 1 year ago

zerberus666 commented 1 year ago

There is wrong bit name in file portserial.c in function void vMBPortSerialEnable( BOOL xRxEnable, BOOL xTxEnable ) :

if( xTxEnable )
    {
        UCSRB |= _BV( TXEN ) | _BV( UDRE );
#ifdef RTS_ENABLE
        RTS_HIGH;
#endif
    }
    else
    {
        UCSRB &= ~( _BV( UDRE ) );
    }

Must be:

if( xTxEnable )
    {
        UCSRB |= _BV( TXEN ) | _BV( UDRIE );
#ifdef RTS_ENABLE
        RTS_HIGH;
#endif
    }
    else
    {
        UCSRB &= ~( _BV( UDRIE ) );
    }

May be UDRIE must be defined like #define UDRIE UDRIE0 //or UDRIE1 in file port.h