Device Specific issues
Before venturing into your latest project, always read the datasheet for the specific device being used, because some devices have features that may interfere with expected pin operations.
An example of a potential problem is that, on some of the earlier devices, bit-4 of PORTA (PORTA.4) exhibits unusual behaviour when used as an output. This is because the pin may have an Open-Drain output rather than the usual bipolar stage as in the rest of the output pins. This means it can pull to ground when set to 0 (low), but it will simply float when set to a 1 (high), instead of going high. This is normal in the older standard 14-bit core devices, and the newer types have SFRs (Special Function Registers) that can enable or disable Open-Drain for each pin.
To make an Open-Drain pin act as expected, add a pull-up resistor between the pin and VDD. A typical value resistor may be between 1KΩ and 33KΩ, depending on the device it is driving. If the pin is used as an input, it behaves the same as any other pin.
Most devices allow low-voltage programming. Again, on the earlier devices, this function, generally, takes over one of the PORTB pins and can cause the device to act erratically if this pin is not pulled low. In normal use with an older standard 14-bit core device, it is best to make sure that Low-Voltage Programming is disabled at the time the device is programmed. By default, the low voltage programming fuse is disabled, however, if the Config directive is used, then it may inadvertently be omitted.
All of the microcontroller’s pins are set to inputs on power-up. If you need a pin to be an output, set it to an output before you use it, or use a BASIC command that does it for you. Once again, always read the PICmicro™ data sheets to become familiar with the particular part.
The name of the port pins on the 6-pin and 8-pin devices is GPIO. The name for the TRIS register is TRISIO: -
GPIO.0 = 1
' Set GPIO.0 high
TRISIO = 0b101010
' Manipulate ins and outs
However, these are also mapped as PORTB, therefore any reference to PORTB on these devices will point to the relevant pin of GPIO.
Some of the more recent devices have PPS (Peripheral Pin Select), which allows the user to choose a pin to use for a peripheral. It does add some extra complexity to a program, but the compiler tries to help, and any command that uses a peripheral will automatically adjust the PPS SFRs to suite, based upon the Pin set in a Declare. Such as HRsout, HRsin, HSerout, HSerin, HPWM etc...