Hi everyone,
I'm working on a project with an LPC microcontroller and trying to write data from a buffer to external flash memory via SPIFI using DMA. The DMA transfer seems to complete without any errors during debugging, but when I check the flash memory afterwards, the data is not written. For setting up SPIFI i use LPCSPIFILIB.
Has anyone encountered a similar issue or could point me to what might be going wrong?
Thanks in advance for any suggestions or guidance!
Best regards,
Serial_Keiler
Code :
uint32_t bufor_data[64] __attribute__((at(0x10081000)));
for (i = 0; i < 0x100; i++)
{
bufor_data[i] = i*2;
}
LPC_GPDMA -> CH[0].CONTROL = 0x0;
LPC_GPDMA -> CH[0].CONFIG = 0x0;
LPC_CREG -> DMAMUX = 0x0;
LPC_GPDMA -> CH[0].CONFIG |= (5 << 11);
LPC_GPDMA -> CH[0].CONTROL |= ((1<<19)|(1<<25)|(1<<26));
LPC_GPDMA -> CH[0].SRCADDR = 0x10081000;
LPC_GPDMA -> CH[0].DESTADDR = 0x40003014;
LPC_SPIFI -> STAT |= SPIFI_STAT_RESET;
LPC_SPIFI -> STAT |= SPIFI_STAT_INTRQ;
LPC_SPIFI -> CMD |= SPIFI_WRITE_ENABLE;
while(LPC_SPIFI->STAT & (1<<1))
{
}
while (pSpifi->pFamFx->devGetStatus(pSpifi) & 1)
{
}
LPC_SPIFI -> ADDR = 0x14000000;
LPC_SPIFI -> CTRL |= (1<<31);
LPC_GPDMA -> CH[0].CONFIG |= 0x1;
NVIC_ClearPendingIRQ((IRQn_Type)30);
NVIC_EnableIRQ((IRQn_Type)30);
LPC_SPIFI -> CTRL |= (1<<22);
LPC_SPIFI -> STAT |= SPIFI_STAT_RESET;
LPC_SPIFI -> CMD = 0;
LPC_SPIFI -> CMD |= (0x02<<24) | (1 << 15) | (256);
while (LPC_SPIFI->STAT & (1<<1))
{
}
while (pSpifi->pFamFx->devGetStatus(pSpifi) & 1)
{
}