SPI DMA interrupt issue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SPI DMA interrupt issue

1,339 Views
jasonedn
Contributor II

I'm writing the second boot loader for LPC54101. When it jumps from boot to application, the SPI DMA interrupt never fired again, but other interrupts such as tick did. The boot and application use the SPI DMA initialization codes. 

The jump codes are below.

void jumpToUserApp( void )
{
USER_ENTRY_PFN user_entry;
user_entry = (USER_ENTRY_PFN)*((uint32_t*)(APP_IMAGE_START + 4));

// stop all interrupts
__disable_irq();
__set_CONTROL(0);

__set_MSP(*(uint32_t *)APP_IMAGE_START); // load stack pointer with initial value
(user_entry)();
}

 

The SPI DMA initialization codes:

// Config SPI
spi_slave_config_t slaveConfig;
SPI_SlaveGetDefaultConfig(&slaveConfig);
slaveConfig.sselPol = (spi_spol_t)kSPI_SpolActiveAllLow;
slaveConfig.fifoConfig.enableTxFifo = true;
slaveConfig.fifoConfig.enableRxFifo = true;
slaveConfig.fifoConfig.txFifoSize = 3;
slaveConfig.fifoConfig.rxFifoSize = 3;
slaveConfig.fifoConfig.txFifoThreshold = 3;
slaveConfig.fifoConfig.rxFifoThreshold = 3;
SPI_SlaveInit(SPI0, &slaveConfig);

// Config DMA
DMA_Init(DMA0);
DMA_EnableChannel(DMA0, 9);
DMA_EnableChannel(DMA0, 8);
DMA_SetChannelPriority(DMA0, 9, kDMA_ChannelPriority0);
DMA_SetChannelPriority(DMA0, 8, kDMA_ChannelPriority1);

DMA_CreateHandle(&s_slaveTxHandle, DMA0, 9); 

DMA_CreateHandle(&s_slaveRxHandle, DMA0, 8); 

{
//DMA_EnableChannelPeriphRq( DMA0, 8 );
//DMA_EnableChannelPeriphRq( DMA0, 9 );
}

NVIC_SetPriority(DMA0_IRQn, 2);

// Create handle for slave instance
SPI_SlaveTransferCreateHandleDMA(SPI0, &s_slaveHandle, SPI_SlaveUserCallback, NULL, &s_slaveTxHandle, &s_slaveRxHandle);

// Set slave transfer ready to receive/send data
s_xfer.txData = (uint8_t*) &s_txSpiCmd;
s_xfer.rxData = (uint8_t*) &s_rxSpiCmd;
s_xfer.dataSize = 3;

// Start SPI
SPI_SlaveTransferDMA(SPI0, &s_slaveHandle, &s_xfer);

0 Kudos
Reply
3 Replies

1,102 Views
AldoG
NXP TechSupport
NXP TechSupport

Hello,

I see that you disable all interrupts, did you enable it back?

Best Regards,

Aldo.

0 Kudos
Reply

1,102 Views
jasonedn
Contributor II

Hi Aldo,

Thanks for your reply. I did enable it back, but it didn't work. Now I found that it was caused by DMA. When SPI DMA mode was disabled and only SPI interrupt was enabled, it worked properly. However I don't know the root cause. It was easy to reproduce. You can a simple DMA SPI slave application with FreeRTOS and jumps to itself after first run. The DAM interrupt works in the first time and doesn't after jumping.

0 Kudos
Reply

1,102 Views
AldoG
NXP TechSupport
NXP TechSupport

Hi,

sorry for the delay,

Could you share your test code?

If not a good idea would be de initialize the DMA and re initialize it.

Regards,
Aldo.

0 Kudos
Reply