Skip to content

Commit bf1bb41

Browse files
author
Anoop Kumar
committed
MPAE-16733: Readme file updated
1 parent 0e042ef commit bf1bb41

File tree

1 file changed

+55
-52
lines changed

1 file changed

+55
-52
lines changed

README.md

Lines changed: 55 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,56 @@
22

33
[![MCHP](images/microchip.png)](https://www.microchip.com)
44

5-
# UART I/O Expander: Host Implementation using PIC16F15276
5+
# UART I/O Expander: Host Implementation Using PIC16F15276
66

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.
89

910
## Introduction
1011

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.
1213

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.
1417

1518
## Related Documentation
1619

1720
- [PIC16F15276 Product Page](https://www.microchip.com/en-us/product/PIC16F15276)
1821
- [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)
2124
- [PIC16F15244 Code Examples on GitHub](https://github.com/microchip-pic-avr-examples?q=pic16f152&type=all&language=&sort=)
2225
- [PIC16F152xx MCU Family Video](https://youtu.be/nHLv3Th-o-s)
2326

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.***
38+
39+
## Hardware Used
40+
41+
* [PIC16F15276 Curiosity Nano Board](https://www.microchip.com/en-us/development-tool/EV35F40A)
42+
* [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+
2446
## Description
2547

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.
2749

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.
2951

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.
3153

32-
<p align="center">
54+
<p align="left">
3355
<img width=500 height=auto src="images/blk_diag.png">
3456
<br>Figure 1: Block Diagram <br>
3557
</p>
@@ -39,15 +61,15 @@ On host device, on-board switch of the PIC16F15276 Curiosity Nano board is used
3961
- The client receives the command from the host device over UART interface.
4062
- 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.
4163

42-
# Seven Segment Display(SSD)
64+
# Seven Segment Display (SSD)
4365

4466
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.
4567

4668
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.
4769

4870
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.
4971

50-
<p align="center">
72+
<p align="left">
5173
<img width=auto height=auto src="images/ssd_diag.png">
5274
<br>Figure 2: SSD Segment Naming Conventions <br>
5375
</p>
@@ -70,68 +92,49 @@ Seven Segment Hex values:
7092
**Resistor Value Calculations**
7193

7294
I<sub>f</sub> forward current (I<sub>f</sub>) is 20 mA
73-
I<sub>f</sub> forward voltage (V<sub>f</sub>) is 2.2 V
95+
I<sub>f</sub> forward voltage (V<sub>f</sub>) is 2.2V
7496
Input voltage (V<sub>in</sub>) is 5V
7597

7698
Resistor ( R ) = (V<sub>in</sub> – V<sub>f</sub> ) / ( I<sub>f</sub> ) = 140 ohms
7799

78100
***Note: 330 or 470 ohms resistor will be used.***
79101

80-
<p align="center">
102+
<p align="left">
81103
<img width=auto height=auto src="images/ckt_diag.png">
82104
<br>Figure 3: SSD LED Resistor Driver Circuit <br>
83105
</p>
84106

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.***
96-
97-
## Hardware Used
98-
99-
* [PIC16F15276 Curiosity Nano Board](https://www.microchip.com/en-us/development-tool/EV35F40A)
100-
* [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-
104107
## Application Firmware
105108

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.
107110

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.
109112

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.
111114

112115
## Hardware Setup
113116

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.
115118

116-
<p align="center">
119+
<p align="left">
117120
<img width=600 height=auto src="images/setup.png">
118121
<br>Figure 4: Hardware Setup <br>
119122
</p>
120123

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.***
122125

123126
## Operation
124127

125128
* Make the hardware connections as shown in the Hardware Setup. Power up the Curiosity Nano board using micro-USB cable.
126129
* Download the firmware available from the GitHub code example page.
127130
* 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 host side, the on-board Switch Press event transmits the command to the client through UART interface.
132+
* On the host side, the on-board LED indicates the Switch Press event and indicates which command to be sent to the client.
133+
* On the client side, 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.
131134

132135
## Conclusion
133136

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.
135138

136139
## Appendix
137140

@@ -153,37 +156,37 @@ MPLAB<sup>®</sup> Code Configurator is a graphical programming environment that
153156
- Set Clock Source as HFINTOSC
154157
- Set HF Internal Clock as 8_MHz
155158

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.
157160

158161
The following figure shows the clock configuration setting in MCC tool.
159162

160-
<p align="center">
163+
<p align="left">
161164
<img width=600 height=auto src="images/clk_config.png">
162165
<br>Figure 5: Clock Configuration <br>
163166
</p>
164167

165168
- Timer 2 Configuration
166169

167-
Configure Timer2 in HLT mode for switch debouncing functionality with the following configuration.
170+
Configure Timer2 in HLT mode for switch debouncing with the following configuration:
168171

169172
- Enable Timer checkbox
170173
- Control Mode – Monostable
171174
- Ext Reset – T2INPPS
172175
- Start/Reset Option – Start on rising edge on TMR2_ers
173-
- Clock Source – MFINTOSC 31.25kHz
176+
- Clock Source – MFINTOSC 31.25 kHz
174177
- Polarity – Rising Edge
175178
- Prescaler – 1:16, Postscaler – 1:1
176-
- Time Period – 100ms
179+
- Time Period – 100 ms
177180
- Enable Timer Interrupt checkbox
178181

179-
<p align="center">
182+
<p align="left">
180183
<img width=600 height=auto src="images/tmr_config.png">
181184
<br>Figure 6: Timer 2 Configuration <br>
182185
</p>
183186

184187
- EUSART Configuration
185188

186-
<p align="center">
189+
<p align="left">
187190
<img width=600 height=auto src="images/uart_config.png">
188191
<br>Figure 7: EUSART Configuration <br>
189192
</p>
@@ -194,14 +197,14 @@ The following images informs about the pin usage in the project.
194197

195198
1. Host Device
196199

197-
<p align="center">
200+
<p align="left">
198201
<img width=600 height=auto src="images/pin_config.png">
199202
<br>Figure 8: Pin Configuration (Host) <br>
200203
</p>
201204

202205
2. Client Device
203206

204-
<p align="center">
207+
<p align="left">
205208
<img width=600 height=auto src="images/pin_config_client.png">
206209
<br>Figure 9: Pin Configuration (Client) <br>
207210
</p>

0 commit comments

Comments
 (0)