In this use case, the PMC module is configured to start the Slow Clock from an attached 32KHz crystal, and start one of the Programmable Clock modules sourced from the Slow Clock divided down with a prescale factor of 64.
Setup
Prerequisites
- Parallel Input/Output Controller (pio)
Code
The following code must be added to the user application:
pio_set_peripheral(
PIOA, PIO_PERIPH_B, PIO_PA17);
Workflow
- Configure the PCK1 pin to output on a specific port pin (in this case, PIOA pin 17) of the microcontroller.
pio_set_peripheral(
PIOA, PIO_PERIPH_B, PIO_PA17);
- Note
- The peripheral selection and pin will vary according to your selected SAM device model. Refer to the "Peripheral Signal Multiplexing on I/O
Lines" of your device's datasheet.
Use case
The generated PCK1 clock output can be viewed on an oscilloscope attached to the correct pin of the microcontroller.
Example code
Add to application C-file:
Workflow
- Switch the Slow Clock source input to an external 32KHz crystal:
- Switch the Programmable Clock module PCK1 source clock to the Slow Clock, with a prescaler of 64:
- Enable Programmable Clock module PCK1:
- Enter an infinite loop: