Has anyone ever had trouble getting the USART to release the TX PORT pin?
We are using a Mega48V and take control of PORTD.1 as a port pin first. We then initialise the USART and send some bytes. Works fine.
After that we set all USART registers to 0x00 (which is supposed to release control of PORTD.1), but it doesn't! Writing anything to PORTD.1 (even after re-initialising the port) shows no output at all. If we SLEEP the micro at that point and wake it up again with a pin-change interrupt all works fine again (until the USART gets control again and we lose PORTD.1 once again).
We use PORTD.0 as a normal port pin. We don't use RX (so UCSR0B=0x08 for TX only), but there seems to be an interaction between the 2 pins. When PORTD.0 is written to, the USART doesn't release. If PORTD.0 is left alone, the USART releases PORTD.1
The whole process is repeatable.
Toggle PORTD.1 a few times
Send some bytes
Write all USART registers to 0x00
Toggle PORTD.1 a few times <== doesn't work
Leave the first line out and all works fine.
Cheers - Frank