Basys MX3™ Board Reference Manual
There is one digital signal to control each color component. Using either 0 or 1 values for these signals will only
give the user a limited number of colors (two colors for each component), so most of the time this is not enough in
applications using the RGB feature. The solution is to send a sequence of 1 and 0 values on these digital lines,
switched rapidly with a frequency higher than human perception. The "duty factor" will finally determine the
color, as the human eye will "integrate" the discrete illumination values into the final color sensation.
The most used approach in solving this problem is the use of pulse-width modulation (PWM) signals. Another
approach is the use of pulse-density modulation (PDM). These methods are explained in the
Using PWM
and
RGB LED Implemented Using PDM
6.1
Connectivity
Schematic
Label
Name
R
LED8_R
G
LED8_G
B
LED8_B
6.2
Functionality
6.2.1 RGB LED Implemented Using PWM
The percentage of each period that the pulse is high determines the signals "duty cycle". Figure 6.2 shows how
different duty cycles are implemented using PWM.
Using this method, the intensity of each component of the RGB LED is determined by the duty cycle being applied.
PWM is most often implemented in the microcontroller using the output compare (OC) peripheral modules along
with a timer.
One timer (Timer y) is assigned to the OC module. Setting the PRy register of the timer will set the PWM period.
Setting the OCxRS register of the OC module will set the actual duty cycle.
The PIC32 datasheet displayed in Fig. 6.3 below explains how one period of the PWM is generated.
Copyright Digilent, Inc. All rights reserved.
Other product and company names mentioned may be trademarks of their respective owners.
sections.
PIC32 Pin
Description
Signal corresponding to the R component of
AN25/RPD2/RD2
the RGB
Signal corresponding to the G component of
RPD12/PMD12/RD12
the RGB
Signal corresponding to the R component of
AN26/RPD3/RD3
the RGB
Table 6.1. RGB LED connectivity.
Figure 6.2. PWM duty cycle.
RGB LED Implemented
Page 19 of 56
Need help?
Do you have a question about the Basys MX3 and is the answer not in the manual?
Questions and answers