Hello,
I try to implement AES encryption using DMA as it is proposed in Design Note DN108.
Unfortunately after having configured the channel for the key download, and set the ENCCS.START_CMD the ENCCS.RDY will never come up.
This is IMHO the problematic section:
dma_ch_0.SRCADDRH = HI_UINT16(key);
dma_ch_0.SRCADDRL = LO_UINT16(key);
// Set DMA transfer count according to key length (128 bits = 16 bytes)
dma_ch_0.LENL = AES_NUM_BYTES_OF_AES_BLOCK;
// Arm DMA channel 0 (DMAARM.DMAARM0 = 1),
// and apply 45 NOP’s to allow the DMA arming to actually take effect.
DMAARM |= 0x01;
asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");
asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");
asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");
asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");
asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");
// Download key (Set ENCCS.CMD = 10b),
// and start corresponding AES process (ENCCS.ST = 1)
ENCCS = (uint8_t)opMode | ENCCS_CMD_LOADKEY | ENCCS_START_CMD; // ENCCS = 0x04 | 0x01;
// Monitor AES coprocessor (ENCCS.RDY) to wait until key downloaded
while (!(ENCCS & 0x08)); <---------- this will loop forever???
Or are there working examples out there?
Any help appreciated.
Regards,
Thomas