I am trying to retrofit a project with a enable pin and at the moment the least difficult way is to use pin 18 (serial1 TX) as an output pin to enable/disable a sensor output. I am using Serial1 RX to receive the sensor output so I can't just entirely remove the serial function of Serial1.
I tried to set pin 18 as output and set it to LOW. It didn't work. It must be driven by something else when it's used as TTL serial.
Then I realized that I should dig into the library code. What I found there, combined with doc2549 is that I can reset the register bit that enables the TX. This way I can use the pin again as gpio.
Is the above the correct way to do this?
BTW, is there any difference in value of TXEN1 and TXEN2, etc? Are they just trying to make things more general so in other MCU if the different TX enable pins are NOT the same bit location, they still work?
Thanks for reading!