-
HSEROUT Disable
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.
[QUOTE'Define hserout parametersDEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 20h
DEFINE HSER_BAUD 2400
DEFINE HSER_CLROERR 1 'clear overflow error
APFCON.7 = 1 'rx on ra1 (16f1823)
APFCON.2 = 1 'tx on pin ra0 (16f1823) ][/QUOTE]
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.
-
Re: HSEROUT Disable
Hi,
Try something like
Code:
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.
-
Re: HSEROUT Disable
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