PDA

View Full Version : HSEROUT Disable



Dick Ivers
- 26th January 2012, 02:11
Is there any way to disable the hserout function once it's set in place with DEFINES? I found that the pins assigned to the hardware function cannot be used for anything else.




I use hserout briefly at the start of my program. Later, I would to use pin RA0 for something else, but the circuit does work. Oddly, the debug function does not have any problem with this kind of switching.

HenrikOlsson
- 26th January 2012, 06:16
Hi,
Try something like

SPEN VAR RCSTA.7 ' Serial port enable

USART_OFF:
SPEN = 0

USART_ON:
SPEN = 1

You MAY (but I don't think it's neccessary) also need to toggle the TXEN-bit, it's in the TXREG somewhere...

/Henrik.

Dick Ivers
- 26th January 2012, 23:50
Henrick,
Your suggestion worked.
It's the TX pin that I wanted to free up after using hersout at the top of my program. So, I inserted this line.

TXSTA.5 = 0 'disable transmit function.

Later, the function is re-enabled:

TXSTA.5 = 1

I should have read the data sheet more carefully.
Thanks,
Dick