38.3.2.1 Operation Modes
The CRCSCAN peripheral supports Scan-In-Sleep mode and the Manual mode operation. The mode is set in the CRC Source (SRC) bit field of the Control A (CRCSCAN.CTRLA) register. For Idle sleep mode operation, configure SRC with the desired section of the Flash to scan (BOOT, CODE or DATA). For the Manual mode operation, set SRC to MANUAL.
Scan-In-Sleep Mode
In Scan-In-Sleep mode, the CRCSCAN peripheral has access to the Flash only when the CPU is in Idle sleep mode. If a scan is enabled, the scan will start when the CPU enters Idle sleep mode, and the scan will pause when the CPU wakes up. If the CPU goes to sleep again, the scan will resume at the address where it left off. This operation will continue until the entire selected memory range has been scanned. An interrupt can optionally be triggered when the scan is complete.
The CRCSCAN peripheral has a built-in counter that, when enabled, will set an interrupt flag every 32 scanned words. This counter is enabled by writing to the Enable Periodic Timer (PEREN) bit in the CRCSCAN.CTRLA register. Its interrupt can be enabled by writing to the Scan Period Done Interrupt Enable (PERIOD) bit in the Interrupt Control (CRCSCAN.INTCTRL) register. If enabled, the interrupt will cause the CPU to leave Idle sleep and allow the application to do various housekeeping tasks between scanning. Continue scanning by clearing the Scan Period Done (PERIOD) bit in the Interrupt Flags (CRCSCAN.INTFLAGS) register and re-enter the Idle sleep mode.
Other sources can wake up the CPU even when the Period Interrupt is enabled. In this case, the periodic timer is frozen while the CPU is awake, and will continue where it froze after re-entering Idle sleep mode.
If the periodic timer is enabled without the period interrupt enabled, the CRC will pause scanning of more Flash words when the flag is set without waking up the CPU. Upon waking up from a different source clearing the PERIOD flag in INTFLAGS will cause the scan to continue.
A CRC error detected during the scan will set an NMI request if the Enable NMI Trigger
(NMIEN) bit in the CRCSCAN.CTRLA register is ‘1
’.
Manual Mode
The Manual mode allows the application to calculate CRC on a data stream by writing the bytes in the stream to the Input Data (CRCSCAN.DATA) register. CRC-16 or CRC-32 is used in the MANUAL mode, depending on the value of the CRC Source Select (CRCSEL) bit in the CRCSCAN.CTRLA register. One clock cycle is required to calculate CRC on a written byte, so data can be written continuously to the CRCSCAN.DATA register without polling the CRC Busy (BUSY) bit in the Status A (CRCSCAN.STATUSA) register between writes. The result of the CRC operation can be read from the CRC Result (CRCSCAN.CRC) register.