View previous topic :: View next topic |
Author |
Message |
Will Reeve
Joined: 30 Oct 2003 Posts: 209 Location: Norfolk, England
|
Redirectable PINs and UART |
Posted: Wed Jun 15, 2011 12:41 pm |
|
|
Thinking out loud! Can you redirect the pins of a UART on PICs such as the PIC18F27J13 in software? I.E. Can you change the function of the pins on the fly in code, it would be nice to redirect the TX of a hardware UART to different pins for a project I am thinking of! |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
Re: Redirectable PINs and UART |
Posted: Wed Jun 15, 2011 5:16 pm |
|
|
Will Reeve wrote: | Thinking out loud! Can you redirect the pins of a UART on PICs such as the PIC18F27J13 in software? I.E. Can you change the function of the pins on the fly in code, it would be nice to redirect the TX of a hardware UART to different pins for a project I am thinking of! |
If you are talking about the Peripheral Pin Select, then the answer is "yes".
But you'll need code to change it on-demand like that -- which isn't hard, but I vaguely remember #pin_select didn't play well mid-stream code. (It's good for start up)
I would experiment. Maybe that's changed -- or maybe someone else has some suggestions.
Cheers,
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Wed Jun 15, 2011 11:16 pm |
|
|
By it's preprocessor command nature, the #pin_select statements work only at start-up. To change the pin allocation during run-time, you have to write to the respective peripheral pin-select registers directly. |
|
|
|