9.1 RGB LED Board Support Service
This section explains how to use the MPLAB Code Configurator (MCC) framework to add RGB LED system service component for using the RGB LED on PIC32-BZ6 Curiosity Board and control its colour through TCC/TC based PWM pulses. The system service helps to add the component on any applications.
The RGB LED System service component has dependency of TCC/TC (Based on the Timer component availablity in the device) timer Plib in order to create PWM pulses based on the RGB colour values. This component, implements both HSV to RGB conversion as well as XY to RGB conversion.

Hardware Requirement
S. No. | Tool | Quantity |
---|---|---|
1 | PIC32-BZ6Curiosity Board | 1 |
2 | Micro USB cable | 1 |
SDK Setup
Refer to Getting Started with Software Development from Related Links.
Developing an Application with RGB LED SERVICE component using MPLAB Code Configurator (MCC)
This section explains the steps required by a user to integrate and use the RGB LED SERVICE component into any application.
-
Create a new harmony project. For more details, see Creating a New MCC Harmony Project from Related Links.
- Ensure that
wireless_system_pic32cxbz_wbz
repo is available locally in the H3 repo environment. - Open MCC. The Wireless Board
Support components will be displayed in available Device Resources -->
Wireless --> Board Support as shown in the below figure.
- Drag RGB LED SERVICE component
from Device Resources to project graph area and accept all Dependencies or
satisfiers (auto-activation components), select “Yes”.
- RGB LED SERVICE connects with
TCC/TC component and does the PWM pulse configurations. Uses default Clock
configuration for TCC/TC. For example, for TCC component, REFO1 with 64 MHz
clock is given to TCC. With this configuration, the PWM pulse frequency is 1954
(period: 511.98 uSec). By changing the Clock frequency will change the PWM pulse
frequency. Note: Refer to device datasheet for PWM pulse frequency calculation.
- There will be a warning note on
the RGB LED SERVICE component. Satisfy the warning by configuring the needed
Pins connected to R,G,B LED's for the PWM waveform output. Note: Refer for device datasheet PPS chapter for pin configuration.For PIC32-BZ6 Curiosity Board,
- Generate the code - For more details on code generation, refer to MPLAB Code Configurator (MCC) Code Generation from Related Links.
- After generating the program
source from MCC interface by clicking Generate Code, the RGB LED service can be
found in the following project directories.
- Compile and Run the project on the board.
RGB LED SERVICE component API's
The following API's are available from RGB LED component, to be called from application where ever needed.
-
Turn off RGB LED.
void RGB_LED_Off(void);
-
Set brightness level.
void RGB_LED_SetBrightnessLevel(uint8_t level);
-
Set the color using Hue and Saturation as parameters.
void RGB_LED_SetLedColorHS(uint16_t hue, uint8_t saturation);
-
Set the color using Hue, Saturation and brightness level as parameters.
void RGB_LED_SetLedColorHSV(uint8_t hue, uint8_t saturation, uint8_t level);
-
Set the color using X and Y as parameters.
void RGB_LED_SetLedColorXY(uint16_t x, uint16_t y);