Knowledge Base
...
Fundamentals
Communications Protocols
UART Remappable Pins
5min
lead in when using a newer device, while the advantages are the enhanced features knowing how to configure and map the pins correctly is become an essential need to know in this topic, we will look briefly at the pic16f1709 and the pic16f18345 and how to configure the remappable pins to use the device this topic is best used in conjunction with the radix nano 20a or radix nano 20b passing the torch to the pic16f18xxx family if you are a pic16f690 user, you may have noticed that the pic16f18344 has been recommended as an alternative device this new device forms part of an exciting family of devices that offers a range of options read more in our pass the torch part 1 recommendations docid 0z puyrgvteewocz9ladm series of articles the pic16f690 , much like its era cousin the pic16f887 is a firm favorite in developing applications, and there is a lot of sample code available when moving to the new device, you would have realized that the comport is no longer hard wired, but rather it has to be mapped to be used configuring the comport previously, configuring the comport was simpler and only required initializing the port as shown below void main (){ uart1 init(9600); // initialise comport } to configure the comport for remappable pins, the mapping must be performed the process includes a little digging in the data sheet, which will be covered at a later stage in our second sample, we will demonstrate the changes step 1 remove the io lock step 2 configure the respective tris registers step3 configure the pins step 4 re lock the io void setupcoms(){ unlock iolock(); trisb7 bit = 0; trisb5 bit = 1; rb7pps = 0b10100; //tx rb5pps = 0b01101; //rx lock iolock(); } void main (){ setupcoms(); // initialise comport } to use and implement the remappable com port, the full code sample is provided below char output\[10]; void initmain() { ansela = 0; anselc = 0; anselb = 0; slrconc = 0; unlock iolock(); trisb7 bit = 0; trisb5 bit = 1; rb7pps = 0b10100; //tx rb5pps = 0b01101; //rx lock iolock(); uart1 remappable init(9600); } void main() { initmain(); while (1) { if (uart1 remappable data ready() == 1) { // if data is received uart1 remappable read text(output, "ok", 10); // reads text until 'ok' is found (maximum 10 characters) uart1 remappable write text(output); // sends back text } } } lead out as with many of the newer devices, there is a higher level of complexity to the devices this translates into some additional work in learning the new device, but the enhancements provided in the new devices is well worth the effort