Skip to content

Commit f197a58

Browse files
Sok Yan PoonSok Yan Poon
authored andcommitted
MPAE-19376: initial code
1 parent fbbbb50 commit f197a58

29 files changed

+2194
-21
lines changed

README.md

Lines changed: 105 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,128 @@
88
</picture>
99
</a>
1010

11-
# Update the title for pic18f56q24-curiosity-nano-explorer-ws2812 here
11+
# PIC18F54Q24 curiosity nano explorer WS2812 RGB LED
1212

13-
<!-- This is where the introduction to the example goes, including mentioning the peripherals used -->
13+
This example demonstrates the setup of the WS2812B on the Curiosity Nano Explorer Board using the PIC18F56Q24 MCU. The WS2812B is a RGB LED that integrates a control circuit and RGB chip in a package. It allows for easy control of multiple LEDs with a single data line, making it ideal for creating colorful lighting effects and displays.
14+
15+
In this project, we will configure the PIC18F56Q24 MCU to communicate with the WS2812B LEDs and create various lighting patterns. The setup includes initializing the necessary peripherals, configuring the data output pin, and writing the code to send the correct timing signals to control the LEDs.
1416

1517
## Related Documentation
1618

17-
<!-- Any information about an application note or tech brief can be linked here. Use unbreakable links!
18-
In addition a link to the device family landing page and relevant peripheral pages as well:
19-
- [AN3381 - Brushless DC Fan Speed Control Using Temperature Input and Tachometer Feedback](https://microchip.com/00003381/)
20-
- [PIC18F-Q10 Family Product Page](https://www.microchip.com/design-centers/8-bit/pic-mcus/device-selection/pic18f-q10-product-family) -->
19+
- [WS2812B Datasheet](https://www.mouser.com/pdfDocs/WS2812B-2020_V10_EN_181106150240761.pdf?srsltid=AfmBOopdvP0PGu8i-pUqTUgdWq0Vi2g59cHWBBg5ldpRW6VLxrdR9cZ1)
20+
- [PIC18F56Q24 Curiosity Nano User Guide](https://ww1.microchip.com/downloads/aemDocuments/documents/MCU08/ProductDocuments/UserGuides/PIC18F56Q24-CNANO-UserGuide-DS50003618.pdf)
21+
- [Curiosity Nano Explorer User Guide](https://ww1.microchip.com/downloads/aemDocuments/documents/MCU08/ProductDocuments/UserGuides/CNANO-Explorer-UserGuide-DS50003716.pdf)
2122

22-
## Software Used
2323

24-
<!-- All software used in this example must be listed here. Use unbreakable links!
25-
- MPLAB® X IDE 5.30 or newer [(microchip.com/mplab/mplab-x-ide)](http://www.microchip.com/mplab/mplab-x-ide)
26-
- MPLAB® XC8 2.10 or a newer compiler [(microchip.com/mplab/compilers)](http://www.microchip.com/mplab/compilers)
27-
- MPLAB® Code Configurator (MCC) 3.95.0 or newer [(microchip.com/mplab/mplab-code-configurator)](https://www.microchip.com/mplab/mplab-code-configurator)
28-
- MPLAB® Code Configurator (MCC) Device Libraries PIC10 / PIC12 / PIC16 / PIC18 MCUs [(microchip.com/mplab/mplab-code-configurator)](https://www.microchip.com/mplab/mplab-code-configurator)
29-
- Microchip PIC18F-Q Series Device Support (1.4.109) or newer [(packs.download.microchip.com/)](https://packs.download.microchip.com/) -->
24+
## Software Used
3025

3126
- MPLAB® X IDE 6.20.0 or newer [(MPLAB® X IDE 6.20)](https://www.microchip.com/en-us/development-tools-tools-and-software/mplab-x-ide)
32-
- MPLAB® XC8 3.0.0 or newer compiler [(MPLAB® XC8 3.0)](https://www.microchip.com/en-us/tools-resources/develop/mplab-xc-compilers/xc8)
27+
- MPLAB® XC8 3.00 or newer compiler [(MPLAB® XC8 3.00)](https://www.microchip.com/en-us/tools-resources/develop/mplab-xc-compilers/xc8)
28+
- MPLAB® Code Configurator (MCC) 5.5.1 or newer [(mplab-code-configurator)](https://www.microchip.com/mplab/mplab-code-configurator)
29+
- Microchip PIC18F-Q Series DFP (1.24.433) or newer [(packs.download.microchip.com/)](https://packs.download.microchip.com/)
3330

3431
## Hardware Used
3532

36-
<!-- All hardware used in this example must be listed here. Use unbreakable links!
37-
- PIC18F47Q10 Curiosity Nano [(DM182029)](https://www.microchip.com/Developmenttools/ProductDetails/DM182029)
38-
- Curiosity Nano Base for Click boards™ [(AC164162)](https://www.microchip.com/Developmenttools/ProductDetails/AC164162)
39-
- POT Click board™ [(MIKROE-3402)](https://www.mikroe.com/pot-click) -->
33+
- [PIC18F56Q24 CURIOSITY NANO EVALUATION KIT ](https://www.microchip.com/en-us/development-tool/ev01e86a)
34+
35+
<p align="center">
36+
<img src="images/pic18f56q24.png" alt="pic18f56q24">
37+
<br>
38+
<em id="figure-1">Figure 1: PIC18F56Q24 CURIOSITY NANO EVALUATION KIT</em>
39+
</p>
40+
41+
- [Curiosity Nano Explorer ](https://www.microchip.com/en-us/development-tool/ev58g97a)
42+
43+
<p align="center">
44+
<img src="images/curiositynanoexplorer.png" alt="Curiosity Nano Explorer">
45+
<br>
46+
<em id="figure-2">Figure 2: Curiosity Nano Explorer</em>
47+
</p>
48+
49+
- USB type C cable
4050

4151
## Setup
52+
Block Diagram below shows how to connection and of MCU and WS2812B.
53+
54+
<p align="center">
55+
<img src="images/MCU project.png" alt="Block Diagram">
56+
<br>
57+
<em id = "figure-3">Figure 3: Block Diagram</em>
58+
</p>
59+
</p>
60+
61+
Follow the steps below to set up and run the example:
62+
63+
1. Connect the PIC18F56Q24 MCU to the Curiosity Nano Explorer board.
64+
2. Connect the PIC18F56Q24 MCU to your computer using a USB cable.
65+
3. Make sure the pin WS2812B-RGB is connected to the data line of the WS2812B in the Curiosity Nano Explorer board.
66+
4. Create a new project in MPLAB® X IDE and open MCC. If first time using MCC, follow this [Getting Started with MCU Projects Using MPLAB® Code Configurator (MCC) Melody - Developer Help](https://developerhelp.microchip.com/xwiki/bin/view/software-tools/frameworks/mcc-melody/getting-started/)
67+
5. Configure the output pin for the WS2812B LEDs, as shown in [Figure 7](#figure-7).
68+
6. Write the code to generate the correct timing signals for the WS2812B LEDs.
69+
7. Compile and program the code into the PIC18F56Q24 MCU.
70+
8. Observe the lighting patterns and effects created by the LEDs.
71+
72+
### Pin Setup
73+
The [User Guide](https://ww1.microchip.com/downloads/aemDocuments/documents/MCU08/ProductDocuments/UserGuides/CNANO-Explorer-UserGuide-DS50003716.pdf) for the Curiosity Explorer Nano board provides the pin mappings.
74+
75+
<p align="center">
76+
<img src="images/ExplorerWS2812.png" alt="ExplorerWS2812">
77+
<br>
78+
<em id = "figure-4">Figure 4: Explorer WS2812B Pin Mappings</em>
79+
</p>
80+
</p>
81+
82+
As shown in [Figure 4](#figure-4) above, pin IO 27 of the Curiosity Explorer Nano board is connected to the data line of the WS2812B LEDs.
83+
84+
<p align="center">
85+
<img src="images/PIC18F56Q24_CuriosityNano.png" alt="CNANO_PINS">
86+
<br>
87+
<em id="figure-5">Figure 5: PIC18F56Q26 Pin Mappings</em>
88+
</p>
89+
</p>
90+
91+
Pin mapping for PIC18F56Q24 can be find in [PIC18F56Q24 User Guide](https://ww1.microchip.com/downloads/aemDocuments/documents/MCU08/ProductDocuments/UserGuides/PIC18F56Q24-CNANO-UserGuide-DS50003618.pdf#page=6)
92+
93+
Based on [Figure 5](#figure-5) and [Figure 6](#figure-6), the pin IO 27 of the Curiosity Explorer Nano board is connected to the data line of the WS2812B LEDs. Ensure that the jumper is connected to link the pins **WS2812B-RGB** on the Curiosity Explorer Nano Board.
94+
95+
The pin in this example project is connected to pin RE0 of the PIC18F56Q24 MCU. This pin is required to be configured as an output pin in MCC.
96+
97+
<p align="center">
98+
<img src="images/CuriosityNanoExplorerPinouts.png" alt="CNANO_PINS">
99+
<br>
100+
<em id="figure-6">Figure 6: Curiosity Nano Explorer Pinouts</em>
101+
</p>
102+
</p>
103+
104+
Pinout for CNANO Socket can be find in the [Curiosity Nano Explorer User Guide](https://ww1.microchip.com/downloads/aemDocuments/documents/MCU08/ProductDocuments/UserGuides/CNANO-Explorer-UserGuide-DS50003716.pdf#page=9)
105+
106+
In MCC, select RE0 as output pin as shown in the [Figure 7](#figure-7) below. RE0 is renamed to be RGB in the Pin configuration window as shown in [Figure 8](#figure-8) below.
107+
108+
<p align="center">
109+
<img src="images/PinGrid_View.png" alt="PinGridView">
110+
<br>
111+
<em id="figure-7">Figure 7: Pin Grid View for LED Output</em>
112+
</p>
113+
</p>
114+
115+
<p align="center">
116+
<img src="images/Pin Name.png" alt="Pin Name">
117+
<br>
118+
<em id="figure-8">Figure 8: Pin Name for LED Output</em>
119+
</p>
120+
</p>
121+
122+
MCC setup remain default, only adding 1 output pin for this example, the next step is to write the code to send the timing signals required by the WS2812B LEDs.
42123

43-
<!-- Explain how to connect hardware and set up software. Depending on complexity, step-by-step instructions and/or tables and/or images can be used -->
124+
### Code setup
125+
For complete application code and comprehensive description of the implementation, please refer to [main.c](\RGB_WS2812B.X\main.c) for the complete code.
44126

45127
## Operation
128+
After programmed the device, the lighting patterns and effects created by the WS2812B LEDs should be obsereved. If not, ensure that:
46129

47-
<!-- Explain how to operate the example. Depending on complexity, step-by-step instructions and/or tables and/or images can be used -->
130+
The output pin is correctly configured and connected to the data line of the WS2812B LEDs.
131+
The code is correctly generating the timing signals required by the WS2812B LEDs.
48132

49133
## Summary
134+
This document provides a guide for setting up and running an example project that demonstrates the control of WS2812B RGB LEDs using the PIC18F56Q24 MCU on the Curiosity Nano Explorer Board. It includes steps for hardware setup, software configuration, and code implementation. The document also provides links to related documentation, lists the required software and hardware, and describes the features and prerequisites for the project. Detailed instructions are given for configuring the output pin and writing the code to control the LEDs. Finally, it offers guidelines for verifying the correct operation of the project and troubleshooting any issues.
50135

51-
<!-- Summarize what the example has shown -->

RGB_WS2812B.X/Makefile

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#
2+
# There exist several targets which are by default empty and which can be
3+
# used for execution of your targets. These targets are usually executed
4+
# before and after some main targets. They are:
5+
#
6+
# .build-pre: called before 'build' target
7+
# .build-post: called after 'build' target
8+
# .clean-pre: called before 'clean' target
9+
# .clean-post: called after 'clean' target
10+
# .clobber-pre: called before 'clobber' target
11+
# .clobber-post: called after 'clobber' target
12+
# .all-pre: called before 'all' target
13+
# .all-post: called after 'all' target
14+
# .help-pre: called before 'help' target
15+
# .help-post: called after 'help' target
16+
#
17+
# Targets beginning with '.' are not intended to be called on their own.
18+
#
19+
# Main targets can be executed directly, and they are:
20+
#
21+
# build build a specific configuration
22+
# clean remove built files from a configuration
23+
# clobber remove all built files
24+
# all build all configurations
25+
# help print help mesage
26+
#
27+
# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
28+
# .help-impl are implemented in nbproject/makefile-impl.mk.
29+
#
30+
# Available make variables:
31+
#
32+
# CND_BASEDIR base directory for relative paths
33+
# CND_DISTDIR default top distribution directory (build artifacts)
34+
# CND_BUILDDIR default top build directory (object files, ...)
35+
# CONF name of current configuration
36+
# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration)
37+
# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration)
38+
# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration)
39+
# CND_PACKAGE_DIR_${CONF} directory of package (current configuration)
40+
# CND_PACKAGE_NAME_${CONF} name of package (current configuration)
41+
# CND_PACKAGE_PATH_${CONF} path to package (current configuration)
42+
#
43+
# NOCDDL
44+
45+
46+
# Environment
47+
MKDIR=mkdir
48+
CP=cp
49+
CCADMIN=CCadmin
50+
RANLIB=ranlib
51+
52+
53+
# build
54+
build: .build-post
55+
56+
.build-pre:
57+
# Add your pre 'build' code here...
58+
59+
.build-post: .build-impl
60+
# Add your post 'build' code here...
61+
62+
63+
# clean
64+
clean: .clean-post
65+
66+
.clean-pre:
67+
# Add your pre 'clean' code here...
68+
# WARNING: the IDE does not call this target since it takes a long time to
69+
# simply run make. Instead, the IDE removes the configuration directories
70+
# under build and dist directly without calling make.
71+
# This target is left here so people can do a clean when running a clean
72+
# outside the IDE.
73+
74+
.clean-post: .clean-impl
75+
# Add your post 'clean' code here...
76+
77+
78+
# clobber
79+
clobber: .clobber-post
80+
81+
.clobber-pre:
82+
# Add your pre 'clobber' code here...
83+
84+
.clobber-post: .clobber-impl
85+
# Add your post 'clobber' code here...
86+
87+
88+
# all
89+
all: .all-post
90+
91+
.all-pre:
92+
# Add your pre 'all' code here...
93+
94+
.all-post: .all-impl
95+
# Add your post 'all' code here...
96+
97+
98+
# help
99+
help: .help-post
100+
101+
.help-pre:
102+
# Add your pre 'help' code here...
103+
104+
.help-post: .help-impl
105+
# Add your post 'help' code here...
106+
107+
108+
109+
# include project implementation makefile
110+
include nbproject/Makefile-impl.mk
111+
112+
# include project make variables
113+
include nbproject/Makefile-variables.mk

0 commit comments

Comments
 (0)