Page 1 of 1

Disabling UART Tx when entering SLEEP mode

Posted: Tue Oct 03, 2017 5:49 am
by streammaster
Hi everyone,

Can somebody please advise me what is the best way of disabling the UART Transmitter pin and converting it to input during SLEEP() mode?

I'm controlling the power of the peripherals, and I shut down all power on the board before entering the SLEEP(), but in SLEEP mode the UART remains active (Tx pin is high on +3.3V basically powering my GPS receiver).
I'm using UART (RS232) serial comm component. I noticed just now that the UART CAL has ability to be 'deinitilised' and release resources, but before i change my entire project (and by now it is basically finished and very large) i'm hoping that there is some way where i can disable transmit by simple C code statement. I tried to use 'Input' entry Flowcode macro by reading the input from the port just before entering the SLEEP, but this is doing nothing here.
The processor is PIC18F47J53 but this subject is i believe quite generic.

Thanks,

Igor

Re: Disabling UART Tx when entering SLEEP mode

Posted: Tue Oct 03, 2017 3:38 pm
by Benj
Hi Igor,

It depends on which UART channel you're using but the following code should work to disable the transmit. Replace 1 with the number of your UART.

Code: Select all

TXSTA1bits.TXEN = 0;
To re-enable after coming back from sleep you can either reverse the C code or call initialise again.

Code: Select all

TXSTA1bits.TXEN = 1;
You can also power down the UART entirely with this code.

Code: Select all

TXSTA1 = 0;
RCSTA1 = 0;