2 Using TMR0 in 8-bit Mode with Periodic Interrupt

This example describes how to configure Timer0 in 8-bit mode and to generate a compare interrupt every 100 ms using LFINTOSC as clock source. A GPIO pin (the development board’s on-board LED) will be configured as output and toggled each time the interrupt occurs. Additionally, the main clock will use a separate clock source (HFINTOSC) and Timer0 will run asynchronously from the main clock.

To achieve the functionality described by the use case, the following actions will have to be performed:
  • System clock initialization
  • Port initialization
  • Timer0 initialization
  • Interrupts initialization
  • Timer0 interrupt handling