43.3.3.1 Initializing the PUKCC and PUKCL
For a project created with Atmel START, the clock initialization is
handled by the initialization function
atmel_start_init
. After a power-on reset, and
when the PUKCC Clock is enabled, a Crypto RAM clear process is
launched. It is mandatory to wait until the end of this process
before using the Crypto Library.
The following code shows how to wait for the Crypto RAM clear process.
while ((PUKCCSR & BIT_PUKCCSR_CLRRAM_BUSY) != 0);
The next task to be done is self-test. From the generated project in Atmel Studio, copy the example for the PUKCC Driver SelfTest and add it to the main source file. This is a mandatory step before using the library. The return values from the SelfTest service must be compared against known values mentioned in the service description (see the Description section in SelfTest).
PUKCC Initialization
void PUKCC_self_test(void)
{
// Clear contents of PUKCLParam
memset(&PUKCLParam, 0, sizeof(PUKCL_PARAM));
pvPUKCLParam = &PUKCLParam;
vPUKCL_Process(SelfTest, pvPUKCLParam);
// In case of error, loop here
while (PUKCL(u2Status) != PUKCL_OK) {
;
}
while (pvPUKCLParam->P.PUKCL_SelfTest.u4Version != PUKCL_VERSION) {
;
}
while (pvPUKCLParam->P.PUKCL_SelfTest.u4CheckNum1 != 0x6E70DDD2) {
;
}
while (pvPUKCLParam->P.PUKCL_SelfTest.u4CheckNum2 != 0x25C8D64F) {
;
}
}
int main(void)
{
/* Initializes MCU, drivers and middleware */
atmel_start_init();
// Wait for Crypto RAM clear process
while ((PUKCCSR & BIT_PUKCCSR_CLRRAM_BUSY) != 0);
// Initialize PUKCC and perform self test
PUKCC_self_test();
while(1)
{
}
}