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

Table 9-1. Hardware Prerequisites
S. No.ToolQuantity
1PIC32-BZ6Curiosity Board1
2Micro USB cable1

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.

Note: It is recommended for the new users of the MPLAB Code Configurator to refer MPLAB® Code Configurator (MCC) User’s Guide in Reference Documentation from Related Links. Users can add/remove different components like peripheral support and other wireless functionality by following steps mentioned in MPLAB® Code Configurator (MCC) Classic, refer MPLAB® Code Configurator (MCC) Classic in Reference Documentation from Related Links.
  1. Create a new harmony project. For more details, see Creating a New MCC Harmony Project from Related Links.

  2. Ensure that wireless_system_pic32cxbz_wbz repo is available locally in the H3 repo environment.
  3. Open MCC. The Wireless Board Support components will be displayed in available Device Resources --> Wireless --> Board Support as shown in the below figure.
  4. Drag RGB LED SERVICE component from Device Resources to project graph area and accept all Dependencies or satisfiers (auto-activation components), select “Yes”.
  5. 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.
  6. 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,
  7. Generate the code - For more details on code generation, refer to MPLAB Code Configurator (MCC) Code Generation from Related Links.
  8. After generating the program source from MCC interface by clicking Generate Code, the RGB LED service can be found in the following project directories.
  9. 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.

  1. Turn off RGB LED.

    void RGB_LED_Off(void);

  2. Set brightness level.

    void RGB_LED_SetBrightnessLevel(uint8_t level);

  3. Set the color using Hue and Saturation as parameters.

    void RGB_LED_SetLedColorHS(uint16_t hue, uint8_t saturation);

  4. Set the color using Hue, Saturation and brightness level as parameters.

    void RGB_LED_SetLedColorHSV(uint8_t hue, uint8_t saturation, uint8_t level);

  5. Set the color using X and Y as parameters.

    void RGB_LED_SetLedColorXY(uint16_t x, uint16_t y);