3 Pattern Generation Using WEX
A fundamental use case of the waveform extension is to set a pattern for the output signals that change periodically. This Pattern Generation mode is helpful if the user wants to use the WEX to override the port pins. When using the WEX in Pattern Generation mode, the output pins from TCE are controlled. The user must enable the Pattern Generation mode and set a desired pattern containing the appropriate code.
A basic example containing the initialization is provided below. The program will toggle the pins (complementary pattern) every 25 μs using software delay ten times. After another 250 μs, a stairs pattern is generated with a 5 μs delay between each step. After another 250 μs delay, the process repeats.
The pins must be configured as outputs by setting the corresponding bits of the Direction register before the initialization of the waveform extension, as described below. Here, Port A pins 0-7 (PA0-7) were chosen. The patterns are best observed using a logic analyzer or eight LEDs to see the signal outputs.
The following two subsections explain configuring the WEX peripheral to do the desired behavior. The first subsection describes how to configure WEX using bare metal code. The second subsection explains how to configure WEX using MCC Melody. The last subsection contains the results.