This configures timer 0 to use location 4 which maps CC channels 1 and 2 to PC0 and PC1 respectively. These two pins are connected to the WSTK LEDs which will then allow us to use PWM to drive the LEDs. The timer prescaler divides the peripheral clock of 48MHz by 1024 resulting in a timer clock signal of 46.875 kHz. We will also configure the timer to count from 0 to 100 and wrap around back to 0 so our PWM frequency will be 468Hz.
Note: The timer configuration can also be modified in run-time with the BGAPI command hardware_timer_init.
The application will create a breathing effect on LEDs 0 and 1 of the WSTK going in opposite directions: when LED0 brightness is ramping up LED1 brightness is ramping down and vice-versa.
We are using a soft timer which triggers every 5 milliseconds to increments/decrements the PWM value by 1 which will change the PWM duty-cycle by 1% on both LEDs.