3.2 Delay Driver Example Source Code Reference
This file contains the APIs to demonstrate the Delay Driver use cases.
This file contains sample source codes to demonstrate the Delay Driver by using it to toggle GPIO pins.
For this example application to work the following needs to be done:
- In MCC Pin Manager Grid View, select a GPIO pin (preferably linked to an LED) to be configured as output. This can be done by clicking the lock square in the same column as the pin number and same row as the label "GPIO Output." The lock square should turn green once selected.
- In MCC Project Resources, go to Pin Module. Rename the selected pin as PIN0. Configure it as digital output by unchecking the box under "Analog" and checking the box under "Output."
- Click the "Generate" button.
- Include the pin_manager.h file in the DELAY_example.c
- Include the DELAY_example.h in main.c file.
- Call the function DELAY_MsExample or DELAY_UsExample inside the while(1) loop to toggle PIN_0 for 500 ms or 50 ms (50000 us) respectively.
Note: 50 ms may be too fast for the naked eye to see, thus it may look like it is not toggling from its initial state. Use an oscillator or logic analyzer to view the changing states.