Thanks for the help……. I found the problem

I was trying to set the RCSTA SPEN bit before I posted the question…… My problem is that for some unknown reason it did not disconnect the internal USART from pins C6 and C7. …several hours of getting nowhere here…

It acted like something was setting up the USART to C6 and 7 even though I did not define it to be that way.

I just tried to do it again today and it worked….. I found this… Before, I still had calls to HSERIN and HSEROUT ( but not in line to be executed ) and the USART setup was removed. I then called RCSTA bit 7 to be 0. This did not disconnect the USART from C6 and 7 as stated in the data sheet.
I had to remove all references to HSERIN and OUT in my code before the RCSTA command would work.

The raw PIC at power up should not be setting up C6 and 7 to be USART pins. They should be I/O and be set to inputs as stated in the data sheet. This is the safe mode so that no pin will drive any external load until told to do so. Without this, a lot of PIC’s could do strange things to connected hardware if fired up un-programmed.

With little more poking around I found a PBP file (PBPPIC18.LIB)…..

It looks like it sets up the USART to be on by default when the HSERXXX command is found anywhere in your code.…. As well as a lot of other stuff like the LCDOUT pin assignments….. perhaps because the development boards use C6 and 7 only for the USART.

(Kind of like Windows setting things up for you in the background and not telling you) Sometimes this is OK but at other times it can mess you up when you don’t understand the rules..

If my assumptions are true, then defining any of this stuff in my code will override the PBPPIC18.LIB file with some exceptions.

I must also assume that settings in any of the .LIB files are PBP only defaults and not what the raw PIC will do by default.

If this is the way it works, that’s cool, but the manual should state this. ..especially if just including the text for a command and not actually using it could pre set a register or pin with some setting other than the Microchip power up default.

On page 76 of the PBP manual the second paragraph tells me that the settings indicated are “defaults”. This lets the user know that the settings are already set somewhere and that if you don’t want it that way that you can change it as indicated or by going to the data sheet

Under the HSERIN command on page 75. for example, the actual HSERIN command and pins are not indicated to be setup as a default when only the command is present in your code.…. I assumed that I had to also define the USART setup in my program or include another .bas include that set up the USART or it would not work…. Not true, just calling HSEROUT in your code invokes the default to be set up at compile time… again I am guessing on how this works based on my testing.

If the manual stated that “ Using the HSEROUT command anywhere your program will configure pins C6 and C7 (PIC pins that can be set as USART I/O) to be connected to the internal USART. If you are not using the internal USART and you want to use pins C6 and C7 for other I/O, you must set the RCSTA SPEN bit to disconnect the internal USART. and not reference or use the command anywhere in your program”

I am still a Newbie with the PBP product so understanding how and when something gets set as a default or needs to be set to work is part of the learning process.

In the case of the USART, I would prefer the user be required to set it up in code for it to work and that pins C6 and C7 be set to regular I/O and inputs.

It looks like the compiler looks for command words to invoke the setup in the INI file. Just including the command in you code sets up the default and also change the pin function if needed. You must not use the command anywhere in your code before you can override the command default settings…. at lease for The USART… cause that’s all I am working with for now…. Learning more every day….

tcbcats