LPC1788 use DMA controller to transfer data from a SPI port to the CRC engine

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

LPC1788 use DMA controller to transfer data from a SPI port to the CRC engine

1,753件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by harper on Wed Aug 20 06:06:51 MST 2014
I have an external memory device connected to the SPI controller SSP1. I need to validate the content of the memory. For this purpose a CRC has been calculated and stored somewhere else (EEPROM).

To validate the memory content I want to pass all data of one SPI cycle to the CRC data register. Currently this is done by writing bytes to memory device what causes clock cycles and to copy the received bytes to the CRC data register.

To improve the performance I would like to utilize the DMA controller. The DMA is able to read the data from the SPI port. I also succeeded to pass some data from the RAM to the CRC engine.

But how can I transfer data directly from on peripheral (SPI) to another (CRC)?? The dummy bytes sent to issue clock cycles could be sent by software or another DMA channel. The only problematic task is the transfer to the CRC.
ラベル(1)
0 件の賞賛
5 返答(返信)

1,544件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by harper23 on Wed Sep 17 22:53:08 MST 2014

Quote: xianghuiwang
Hi, harper23,


Hi xianghuiwang,
thanks for your reply.


Quote: xianghuiwang
Maybe I miss understood your question. I thought you want to directly do CRC on the SPI data without using two DMA steps to store and then DMA to the CRC engine.


No, you didn't misunderstood. The objective is to calculate the CRC of the data that is received from the SPI port. The data should transferred directly from the SPI to the CRC engine in one DMA transfer.
Utilizing the RAM would add a penalty of slowing down the process and should be avoided.


Quote: xianghuiwang
We have not tested this possibility.


Could you test it? I provided the code I used. It failed as it did not change anything in the CRC enging. But probably you find something that coudl be done better.


Quote: xianghuiwang
If we set the destination of the SPI data to the CRC register, we only will get the CRC result but not the SPI data. This was what I mean previously.


Yes that is the desired result. So I read your reply as it would be possible.

Best regards
harper23
0 件の賞賛

1,544件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by xianghuiwang on Wed Sep 17 16:24:43 MST 2014
Hi, harper23,

Maybe I miss understood your question. I thought you want to directly do CRC on the SPI data without using two DMA steps to store and then DMA to the CRC engine.

We have not tested this possibility. If we set the destination of the SPI data to the CRC register, we only will get the CRC result but not the SPI data. This was what I mean previously.

regards,
0 件の賞賛

1,544件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by harper23 on Mon Sep 15 22:10:18 MST 2014
Hello NXP Support,

I have tried your recommendation and I have reported the results as well as the details how I tried.

Was your post based on the assumptions that my objectives are realistic? Is this possible or did you follow the wrong way as I did?
0 件の賞賛

1,544件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by harper23 on Fri Sep 05 06:37:19 MST 2014

Quote: xianghuiwang
Hi,

You can try to set the destination of the SPI DMA to CRC, but you would lose the SPI data. - think this is not what you want.
regards,



Why would I lose SPI data? The CRC engine should be able to calculate the next SUM result within one cycle.

I tried to configure the DMA corresponding to the data sheet.

uint8_t command_echo[5];

// This set of DMA configuration will be applied when the initial data length counts down to zero since the LLI register is set to this array.
uint32_t next_LLI[4] = {
    &LPC_SSP1->DR,                                    // read a byte from SPI
    &LPC_CRC->WR_DATA_BYTE.DATA,    // write the byte to the CRCC
    0,
    0x90000 | GPMDA_DMACCxControl_I      // length ignored when controlled by peripheral
};

// connect DMA with SSP1
LPC_GPDMACH5->CConfig = 0
LPC_GPDMACH5->CLLI = & next_LLI
LPC_GPDMACH5->CSrcAddr = & LPC_SSP1->DR
LPC_GPDMACH5->CDestAddr = command_echo
LPC_GPDMACH5->CControl = size_of_SPI_command + GPDMA_DMACCxControl_DI
LPC_GPDMA->DMAREQSEL &= (1 << GPDMA_CONN_SSP1_Rx)
LPC_GPDMA->Config = GPDMA_DMACConfig_E

// enable DMA channel
LPC_GPDMACH5->CConfig = 
    GPDMA_DMACCxConfig_TransferType(GPDMA_TRANSFERTYPE_P2M) |
    GPDMA_DMACCxConfig_SrcPeripheral(GPDMA_CONN_SSP1_Rx)
LPC_GPDMACH5->CConfig |= GPDMA_DMACCxConfig_E

// connect SSP to DMA
SSP_DMACmd(LPC_SSP1, SSP_DMA_RX, ENABLE)

// send command
LPC_SSP1->DR = cmd1
LPC_SSP1->DR = cmd2
LPC_SSP1->DR = cmd3
LPC_SSP1->DR = cmd4
LPC_SSP1->DR = cmd5
while (!(LPC_SSP1->SR & SSP_SR_TFE)) { }

// send dummy bytes to the SSP that will cause SSP receive cycles
 do
    {
        if (SSPx->SR & SSP_SR_TNF)
        {
            SSPx->DR = 0xFF;
        }
    } while(--length > 0);


But the result is that the CRC SUM register doesn't change at all.
0 件の賞賛

1,544件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by xianghuiwang on Wed Sep 03 09:50:00 MST 2014
Hi,

You can try to set the destination of the SPI DMA to CRC, but you would lose the SPI data. - think this is not what you want.
regards,
0 件の賞賛