Uploading fail in RS485 half duplex mode

78 views
Skip to first unread message

mei

unread,
Feb 19, 2010, 5:10:42 AM2/19/10
to avrub
due to UART 2-byte FIFO RX buffer and receive enabled during
transmitting, any data read from UDR may contain
data previously transmitted. Storing program data fails with error:
Too many retry!
Update fail
, but practically only first page of memory is stored.

so I decided to modify transmitting routine of boot loader:

void WriteCom(unsigned char dat)
{
#if RS485
UCSRBREG(COMPORTNo) = (1 << TXENBIT(COMPORTNo));
RS485Enable();
#endif

UDRREG(COMPORTNo) = dat;
//wait send finish
while(!(UCSRAREG(COMPORTNo) & (1<<TXCBIT(COMPORTNo))));
UCSRAREG(COMPORTNo) |= (1 << TXCBIT(COMPORTNo));

#if RS485
UCSRBREG(COMPORTNo) = (1 << RXENBIT(COMPORTNo));
RS485Disable();
#endif
#if WDG_En
//clear watchdog
wdt_reset();
#endif
}

shao ziyang

unread,
Feb 21, 2010, 6:20:25 AM2/21/10
to av...@googlegroups.com
yes, if you using RS485 you may meet this problem.

I often connect RS485's DE and RE, then when you sending data, RE will be disable, so it will not receive data transmtting.


--
You received this message because you are subscribed to the Google Groups "avrub" group.
To post to this group, send email to av...@googlegroups.com.
To unsubscribe from this group, send email to avrub+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/avrub?hl=en.




--
Best regard

Shaoz...@gmail.com
https://sites.google.com/site/shaoziyang
Reply all
Reply to author
Forward
0 new messages