Disable Uart TX to use as GPIO

Status
Not open for further replies.

xoxu

Member
Hi,

I try to found a solution to disable the tx function of an UART to use the pin as GPIO with the teensy 3.2.
I know that I need to disable UART_C2_TE but that doesn't work...
Code:
Uart.begin(250000);
UART0_C2 |= UART_C2_TE;
wrong method to turn off a bit of a register?

I found that on the core library if that help :

Code:
#ifdef HAS_KINETISK_UART1_FIFO
#define C2_ENABLE		UART_C2_TE | UART_C2_RE | UART_C2_RIE | UART_C2_ILIE
#else
#define C2_ENABLE		UART_C2_TE | UART_C2_RE | UART_C2_RIE
#endif
#define C2_TX_ACTIVE		C2_ENABLE | UART_C2_TIE
#define C2_TX_COMPLETING	C2_ENABLE | UART_C2_TCIE
#define C2_TX_INACTIVE		C2_ENABLE

I wonder if someone have a solution.

Thank you
 
I've not tried it, but wouldn't a simple pinMode() after Serial.begin() help ?

I wondered about that - a test would show it - but I assumed the Serial internal code may get confused - but then if nothing is transmitted I suppose it would never run into that?
 
Something I've been working on uses a multidrop serial connection, so each device needs to set it's UART TX pin to high impedance when it's not transmitting to avoid bus contention. I just do this by calling pinMode right after Serial.begin, on T3.2.

Code:
Serial2.begin(57600);	
pinMode(10, INPUT);

I should imagine you can probably set it as an output and manipulate it with digitalWrite.
 
I want to use this pin with fastled so I don't have a lot of flexibility
But I definitely go to try tomorrow to set to input then output maybe.
I can't use an alternative pin for TX they are all in use
 
Of course the easiest solution is always the better...
A simple pin mode help a lot after the uart begin...

I use the DmxReceiver library with the Fastled one (tricky if you have a fast dmx rate by the way) and I had the fastled.begin then the dmx.begin, you reverse the order and tada!! that work...

Thank you all for the help
 
Status
Not open for further replies.
Back
Top