Using the Rapid General Purpose I/O (RGPIO) for the MCF51QE128 Microcontrollers
QE128 Quick Reference User Guide, Rev. 1.0
14-2
Freescale Semiconductor
void RGPIO_Init(void) {
RGPIO_DIR = 0x0080; // Configure PTE7 pin as output
RGPIO_ENB = 0x0080; // Configure PTE7 as RGPIO pin
}
This is the main function, above are the described called functions. The firmware has an infinite loop and
always toggles three different LEDs. These are three different ways of toggling these LEDs. The first one,
uses a normal GPIO and the instruction is executed in 20 CPU cycles (18 ASM instructions). The second
one, is executed in 6 CPU cycles (6 ASM instructions). The third one, uses the the RGPIO module and the
toggle instruction is executed in 2 CPU cycles (2 ASM instructions).
void main(void) {
MCU_Init(); // Function that initializes the MCU
GPIO_Init(); // Function that initializes the Ports of the MCU
RGPIO_Init(); // Function that initializes the RGPIO module
EnableInterrupts; // enable interrupts
for(;;) {
PTED_PTED3 ^= 1; // Toggles a PTE3. This C command line is executed in 18 CPU cycles
PTED ^= 0x01; // Toggles a PTE0. This instruction is executed in 5 CPU cycles
RGPIO_TOG = 0x0080; // Toggles PTE7. This instruction is executed in 2 CPU cycles
} // loop forever
// please make sure that you never leave this function
}
14.3
Simulation steps
This section describes the necessary steps to observe the differences of using a normal GPIO and RGPIO
module in a V1 microcontroller.
1. Once the firmware is downloaded to the MCU, a simulation window is opened like the figure
shown below.