7/30/2019
Basys MX3 Reference Manual [Reference.Digilentinc]
https://reference.digilentinc.com/reference/microprocessor/basys-mx3/reference-manual?_ga=2.68739409.1349070004.1564406803-1961480359.…
19/52
The RGBLED library from the Basys MX3 library pack contains a commented example of PWM implementation with these features:
LED8_R, LED8_G and LED8_B are mapped to OC3, OC5 and OC4
OC3, OC5 and OC4 are properly configured, together with assigned Timer 2
When a new color is set, its components (R, G and B) are assigned to OC3RS, OC5RS and OC4RS
Pulse-density modulation (PDM) method adjusts both the frequency and length of the “High” pulses in the modulated signal.
A PDM is implemented using a register and an accumulator adder with carry output. The n-bit register can store any binary value from 0 to
2^n-1. In each clock period, the register content is added to the accumulator. The carry bit (overflow of the n-bit accumulator) is the output.
It is “High” as often as the accumulator overflows, so that when large values are added, carry will occur often. The “High” pulse is only 1
clock period long, but more “High” pulses can succeed when the register content is close to maximum.
The RGBLED library from the BasysMX3 library pack contains an example of PDM implementation, with these features:
LED8_R, LED8_G and LED8_B are configured as simple digital outputs.
Timer5 is configured to generate an interrupt every approx. x us
Three 16 bits accumulator are used, one for each color.
In the interrupt service routine, for each color, the 8 bits color value is added to the corresponding 16 bits accumulator.
For each color, the 9th bit of the accumulator is considered the carry bit. The resulted carry bits are assigned to LED8_R, LED8_G
and LED8_B.
For each color, the accumulator is masked so that it only contains an 8 bits value (carry is cleared).
The Basys MX3 board contains a four-digit common anode seven-segment LED () display. Each of the four digits is composed of seven
segments displaying a “figure 8” pattern and a decimal point, with an LED () embedded in each segment. Segment LEDs can be individually
illuminated. Of the number of possible patterns, the ten corresponding to the decimal digits are the most useful.
6.2.2. RGB LED Implemented Using PDM
7. Seven Segment Display