---
title: UART Remappable Pins
slug: uart-remappable-pins
docTags: 
createdAt: 2023-08-14T15:45:04.206Z
---

## 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&#x20;**&#x61;nd the **PIC16F18345&#x20;**&#x61;nd how to configure the remappable pins to use the device.

:::hint{type="success"}
This topic is best used in conjunction with the [Radix Nano 20A](https://www.haventechnik.biz/products/Radix-NANO-20A-16Fxxx-18Fxxx-p559074214) or Radix Nano 20B
:::

## Passing the Torch . . . to the PIC16F18xxx Family

If you are a **PIC16F690&#x20;**&#x75;ser, you may have noticed that the **PIC16F18344&#x20;**&#x68;as been recommended as an alternative device. This new device forms part of an exciting family of devices that offers a range of options.

:::hint{type="info"}
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&#x20;**&#x69;s 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.

```c

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&#x20;

Step 4: Re lock the IO

```c

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:

```c
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.
