You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# UART I/O Expander: Host Implementation using PIC16F15276
5
+
# UART I/O Expander: Host Implementation Using PIC16F15276
6
6
7
-
This code example demonstrates usage of PIC16F15276 microcontroller as a I/O expander in embedded applications, where the PIC16F15276 microcontroller provides additional I/O pins to the main microcontroller through serial communication interface like I2C or SPI or UART. In this code example, use of EUSART peripheral and GPIOs to realize UART I/O expander is demonstrated.
7
+
This code example showcases how the PIC16F15276 microcontroller s used as an I/O expander in embedded applications.
8
+
in this example, the PIC16F15276 microcontroller provides additional I/O pins to the main microcontroller through a serial communication interface like I2C, SPI, or UART.
8
9
9
10
## Introduction
10
11
11
-
The PIC16F152xx family of microcontrollers are available in packages for various embedded applications. The PIC16F15276 simplified feature set includes Peripheral Pin Select (PPS), digital communication peripherals, timers, Enhanced Universal Synchronous Asynchronous Receiver Transmitter (EUSART). In real time applications, EUSART can be configured as a full-duplex asynchronous system or half-duplex synchronous system. Full-Duplex mode is useful for communications with peripheral systems, such as CRT terminals and personal computers. Half-Duplex Synchronous mode is intended for communications with peripheral devices, such as A/D or D/A integrated circuits, serial EEPROMs or other microcontrollers. Several embedded applications use I/O expander to add the additional I/O pins required for the main microcontroller while interfacing standalone IC modules, display modules, for various features implementation. This code example demonstrates implementation of I/O Expander using EUSART peripheral and I/O pins of the PIC16F15276 microcontroller.
12
+
The PIC16F152xx family of microcontrollers are available in packages for various embedded applications. The PIC16F15276 simplified feature set includes Peripheral Pin Select (PPS), digital communication peripherals, timers, and Enhanced Universal Synchronous Asynchronous Receiver Transmitter (EUSART). In real time applications, EUSART can be configured as a full-duplex asynchronous system or half-duplex synchronous system. Full-Duplex mode is useful for communications with peripheral systems, such as CRT terminals and personal computers. Half-Duplex Synchronous mode is intended for communications with peripheral devices, such as A/D or D/A integrated circuits, serial EEPROMs or other microcontrollers.
12
13
13
-
Refer code example [UART I/O Expander Implementation using PIC16F15276](https://github.com/microchip-pic-avr-examples/pic16f15276-cnano-uart-io-expander-client-mplab-mcc.git) for more details about the client device implementation.
14
+
Several embedded applications use I/O expander to add the additional I/O pins required for the main microcontroller while interfacing standalone IC modules display modules for various feature implementation. This code example demonstrates implementation of I/O Expander using EUSART peripheral and I/O pins of the PIC16F15276 microcontroller.
15
+
16
+
For more details about the host device implementation see the [UART I/O Expander: Host Implementation using PIC16F15276](https://github.com/microchip-pic-avr-examples/pic16f15276-cnano-uart-io-expander-host-mplab-mcc.git) code example.
-[PIC16F152xx MCU Family Product Brief](https://ww1.microchip.com/downloads/en/DeviceDoc/40002140A.pdf)
19
-
-[How to use PIC16F15244 Family as an I/O Expander](https://www.microchip.com/en-us/about/blog/design-corner/how-to-use-the-pic16f15244-family-as-an-i-o-expander-for-more-de1)
20
-
-[SPI I/O Expander using PIC16F15276 micrcocontroller](https://github.com/microchip-pic-avr-examples/pic16f15276-cnano-spi-io-expander-host-mplab-mcc.git)
22
+
-[How to Use the PIC16F15244 Family as an I/O Expander](https://www.microchip.com/en-us/about/blog/design-corner/how-to-use-the-pic16f15244-family-as-an-i-o-expander-for-more-de1)
23
+
-[SPI I/O Expander Using PIC16F15276](https://github.com/microchip-pic-avr-examples/pic16f15276-cnano-spi-io-expander-host-mplab-mcc.git)
21
24
-[PIC16F15244 Code Examples on GitHub](https://github.com/microchip-pic-avr-examples?q=pic16f152&type=all&language=&sort=)
22
25
-[PIC16F152xx MCU Family Video](https://youtu.be/nHLv3Th-o-s)
23
26
27
+
## Software Used
28
+
29
+
Microchip’s free IDE, compiler and graphical code generators are used throughout the application firmware development. The tools used for this demo are:
30
+
31
+
*[MPLAB® X IDE](https://www.microchip.com/mplab/mplab-x-ide) 6.15.0 or newer
32
+
*[MPLAB® XC8 Compiler](https://www.microchip.com/mplab/compilers) 2.45.0 or newer
33
+
*[MPLAB® Code Configurator (MCC)](https://www.microchip.com/mplab/mplab-code-configurator) 5.3.7 or newer
34
+
*[Microchip PIC16F1xxxx_DFP Device Support](https://packs.download.microchip.com/) 1.21.368 or newer pack
35
+
* ESUART MCC Melody driver 7.1.5
36
+
37
+
***Note: For running the demo, the installed tool versions must be the same or later. This example is not tested with the previous versions.***
*[Curiosity Nano Base for Click Boards<sup>TM</sup>](https://www.microchip.com/en-us/development-tool/AC164162)
43
+
*[PROTO Xplained Pro Extension Kit](https://www.microchip.com/en-us/development-tool/ATPROTO1-XPRO"PROTO Xplained Pro Extension Kit")
44
+
* Seven Segment Display
45
+
24
46
## Description
25
47
26
-
In this code example, host microcontroller expects to display the numbers on Seven Segment Display (SSD). To interface SSD with the host device, it requires minimum 7 general purpose I/O pins. To minimize the usage of I/O pins on host, a secondary microcontroller is used as client for driving the SSD and, UART serial communication interface to communicate between the host and client device. To establish communication between the host and client device, UART serial communication interface is used.
48
+
In this code example, the host microcontroller expects to display the numbers on Seven Segment Display (SSD). To interface SSD with the host device, it requires minimum seven general purpose I/O pins. To minimize the usage of I/O pins on host, a secondary microcontroller is used as a client for driving the SSD and UART serial communication interface to communicate between the host and client device. To establish communication between the host and client device, the UART serial communication interface is used.
27
49
28
-
For the ease of demonstration, this code example uses PIC16F15276 microcontroller as host microcontroller and another PIC16F15276 microcontroller as client microcontroller. Also, the code example uses PIC16F15276 Curiosity nano development boards for the demonstration.
50
+
For the ease of demonstration, this code example uses two microcontrollers, PIC16F15276 as a host, and PIC16F15276 as a client. Also, the code example uses PIC16F15276 Curiosity Nano Development boards for the demonstration.
29
51
30
-
On host device, on-board switch of the PIC16F15276 Curiosity Nano board is used to send command to the client device through UART interface. The on-board LED is used to notify the user about successful switch press event detection and subsequent UART command transmission by the host. After receiving the command from host, client device drives the respective I/O pins connected to the SSD in a pre-defined sequence, to display numbers from 0 to 9 in the ascending order.
52
+
On host device, on-board switch of the PIC16F15276 Curiosity Nano board is used to send command to the client device through the UART interface. The on-board LED notifies the user about successful switch press event detection and subsequent UART command transmission by the host. After receiving the command from host, the client device drives the respective I/O pins connected to the SSD in a pre-defined sequence, to display numbers from zero to nine in ascending order.
@@ -39,15 +61,15 @@ On host device, on-board switch of the PIC16F15276 Curiosity Nano board is used
39
61
- The client receives the command from the host device over UART interface.
40
62
- The client microcontroller verifies the commands upon reception, if it matches then initiates the number display from 0 to 9 on SSD. It is followed up with SSD value resetting to zero.
41
63
42
-
# Seven Segment Display(SSD)
64
+
# Seven Segment Display(SSD)
43
65
44
66
The 7-segment display consists of seven LEDs arranged in a rectangular fashion. Each of the seven LEDs is called a segment because when illuminated the segment forms part of a numerical to be displayed.
45
67
46
68
An additional 8th LED is sometimes used within the same package thus allowing the indication of a decimal point, (DP) when two or more 7-segment displays are connected to display numbers greater than ten.
47
69
48
70
Each one of the seven LEDs in the display is given a positional segment with one of its connection pins being brought straight out of the rectangular plastic package. These individual LED pins are labelled from a through to g representing each individual LED. The other LED pins are connected and wired to form a common pin. An additional 8th LED is sometimes used within the same package thus allowing the indication of a decimal point, (DP) when two or more 7-segment displays are connected to display numbers greater than ten.
<br>Figure 3: SSD LED Resistor Driver Circuit <br>
83
105
</p>
84
106
85
-
## Software Used
86
-
87
-
Microchip’s free IDE, compiler and graphical code generators are used throughout the application firmware development. Following are the tools used for this demo application:
88
-
89
-
*[MPLAB® X IDE](https://www.microchip.com/mplab/mplab-x-ide) 6.15.0 or newer
90
-
*[MPLAB® XC8 Compiler](https://www.microchip.com/mplab/compilers) 2.45.0 or newer
91
-
*[MPLAB® Code Configurator (MCC)](https://www.microchip.com/mplab/mplab-code-configurator) 5.3.7 or newer
92
-
*[Microchip PIC16F1xxxx_DFP Device Support](https://packs.download.microchip.com/) 1.21.368 or newer pack
93
-
* ESUART MCC Melody driver 7.1.5
94
-
95
-
***Note: For running the demo, the installed tool versions should be the same or later. This example is not tested with the previous versions.***
*[Curiosity Nano Base for Click Boards<sup>TM</sup>](https://www.microchip.com/en-us/development-tool/AC164162)
101
-
*[PROTO Xplained Pro Extension Kit](https://www.microchip.com/en-us/development-tool/ATPROTO1-XPRO"PROTO Xplained Pro Extension Kit")
102
-
* Seven Segment Display
103
-
104
107
## Application Firmware
105
108
106
-
This example is supplemented with two standalone firmware named as host firmware, client firmware.
109
+
This example uses two standalone firmware named host and client firmware.
107
110
108
-
The host firmware uses EUSART peripheral for communication with client. Upon detection of a valid switch press event, the host sends a command to the client over UART interface. Also, the host blinks on-board LED each time a command is successfully sent to the client.
111
+
The host firmware communicates with the client through the EUSART peripheral. When a Valid Switch Press event is detected, the host sends a command to the client over UART interface. Also, the host blinks on-board LED each time a command is successfully sent to the client.
109
112
110
-
The client firmware is comprised of two sections. First section is verifying the command received from the host through UART interface. The second section consists of driving SSD, so the SSD start displaying digits from 0 to 9 in an incrementing order each time a valid command is received from the host. Additionally, the client firmware toggles on-board LED each time after a digit is displayed on the SSD and resets display value to zero when the cycle is completed.
113
+
The client firmware is comprised of two sections. First section is verifying the command received from the host through UART interface. The second section consists of driving SSD, so the SSD start displaying digits from zero to nine in an incrementing order each time a valid command is received from the host. Additionally, the client firmware toggles the on-board LED when digits are displayed on the SSD and resets display value to zero when the cycle is completed.
111
114
112
115
## Hardware Setup
113
116
114
-
The following figure consists of populated PROTO Xplained Pro extension kit, Curiosity Nano Adapter Board and PIC16F15276 Curiosity Nano Evaluation Kit (host and client devices). The figure shows the detailed information about the hardware setup. The populated PROTO Xplained Pro extension kit is interfaced with PIC16F15276 microcontroller using extension header.
117
+
The following figure consists of populated PROTO Xplained Pro extension kit, Curiosity Nano Adapter Board and PIC16F15276 Curiosity Nano Evaluation Kit (host and client devices). The figure shows information about the hardware setup. The populated PROTO Xplained Pro extension kit is interfaced with PIC16F15276 microcontroller using an extension header.
115
118
116
-
<palign="center">
119
+
<palign="left">
117
120
<imgwidth=600height=autosrc="images/setup.png">
118
121
<br>Figure 4: Hardware Setup <br>
119
122
</p>
120
123
121
-
***Note: In order to use on-board mechanical switch on host device, timer is used to avoid the debouncing. Thereby, timer input pin RC3 and pin RB5 (on-board switch), need to be shorted using a jumper. The usage of jumper is required as RB5 pin cannot be selected as timer input through PPS feature of the PIC16F15276 microcontroller.***
124
+
***Note: To use on-board mechanical switch on host device timer is used to avoid the debouncing. Thereby, timer input pin RC3 and pin RB5 (on-board switch), need to be shorted using a jumper. The usage of jumper is required as RB5 pin cannot be selected as a timer input through PPS feature of the PIC16F15276 microcontroller.***
122
125
123
126
## Operation
124
127
125
128
* Make the hardware connections as shown in the Hardware Setup. Power up the Curiosity Nano board using micro-USB cable.
126
129
* Download the firmware available from the GitHub code example page.
127
130
* Build the project using latest version of tools as mentioned in the Software Tools section and flash the generated file on the PIC16F15276 microcontroller.
128
-
* On host-side, onboard switch press event is performed to transmit the command to the client through EUSART interface.
129
-
* On host-side, onboard LED is used as an indicator for the switch press event and indicates command is sent to the client.
130
-
* On client-side, after receiving the command from the host, client device verifies the command and drives the 7 segment LED display to display numbers from 0 to 9. On-board LED of CNANO board toggles for every number display.
131
+
* On the hostside, the on-board Switch Press event transmits the command to the client through UART interface.
132
+
* On the hostside, the on-board LED indicates the Switch Press event and indicates which command to be sent to the client.
133
+
* On the clientside, after receiving the command from the host, client device verifies the command and drives the seven segment LED to display numbers from zero to nine. On-board LED of CNANO board toggles for every displayed number.
131
134
132
135
## Conclusion
133
136
134
-
In many real-world embedded applications, the microcontroller requires to interface with multi-pin standalone IC modules and display units to perform various functionalities. So, the developers have a challenge in effectively using microcontrollers I/O pins for interfacing the external modules without opting an expensive, higher pin and memory variant. This code example demonstrates how cost effective and entry level PIC16F15726 microcontroller can be used as I/O expander using UART interface.
137
+
In many real-world embedded applications, the microcontroller requires to interface with multi-pin standalone IC modules and display units to perform various functionalities. So, the developers have a challenge in effectively using microcontrollers I/O pins for interfacing the external modules without opting an expensive, higher pin and, memory variant. This code example demonstrates how cost effective and entry level PIC16F15726 microcontroller can be used as an I/O expander using UART interface.
135
138
136
139
## Appendix
137
140
@@ -153,37 +156,37 @@ MPLAB<sup>®</sup> Code Configurator is a graphical programming environment that
153
156
- Set Clock Source as HFINTOSC
154
157
- Set HF Internal Clock as 8_MHz
155
158
156
-
The **configurations Bits**(**Project Resources** -> **System**) window in MCC is used for MCU oscillator, Watchdog timer and low voltage programming configuration. The Watchdog timer is disabled in the application.
159
+
The **Configurations Bits**(**Project Resources** -> **System**) window in MCC is used for MCU oscillator, Watchdog timer (WDT) and, low voltage programming configuration. The WDT is disabled in the application.
157
160
158
161
The following figure shows the clock configuration setting in MCC tool.
0 commit comments