DMA to SPI on LPC54606

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

DMA to SPI on LPC54606

ソリューションへジャンプ
3,187件の閲覧回数
DIL98
Contributor II

Hello everyone,

i am trying to write SPI Frames through the DMA module, for the configuration i use MCUXpresso Config Tools. However i fail to correctly set up, there are no SPI frames written at all.

So my question is, is there a guide or something similar?

Also the first frame is different from the data the DMA is supposed to write. So far the SPI is setup and the first frame is successfully written by different code. Do i have to deinitialise the Flexcom module first in order to  initialise it for DMA SPI?

I am sorry if those are to many questions at once and i am thankfull for any help

0 件の賞賛
返信
1 解決策
1,859件の閲覧回数
Petr_H
NXP Employee
NXP Employee

Please find attached a working sample for LPCXpressso 54608 that shows configuration of the DMA, CTIMER and FlexComm SPI via Peripherals tool components where CTimer periodically triggers DMA to perform one SPI frame transfer for each trigger.

The target of the DMA transfer is the SPI FIFO write register which contains both 16-bit data part and configuration part. So, the DMA transfers 32bits at each trigger event from the buffer to the SPI FIFO write register. The buffer needs to be prepared including both data and configuration parts, which is a little disadvantage of this method, as it consumes 4 bytes for each SPI frame (regardles frame length, which can be 1-16 bits).

The TCD (Transfer Control Descriptor) is configured in the DMA component to reload itself after the the length configured in the DMA component is exhausted so the transfer starts from the beginning of the buffer without any software intervention.

The trigger needs to be routed using the inputmux register, this is done in the main code after the peripheral initialization.

Please note that I haven't used DMA mode of the SPI SDK driver is not suited for repeated and linker transfers transfers triggered by hardware. The SPI driver is used only for initial setup with Polling mode.

As this topic is quite complex and there are many possibilities, we are planning to publish more detailed example in the config tools knowledge base

best regards

Petr Hradsky

Config Tools Team

 

 

元の投稿で解決策を見る

15 返答(返信)
3,118件の閲覧回数
Petr_H
NXP Employee
NXP Employee

Hi,

We would need to know the settings that you configured in the project and how you are calling the SDK functions. If you could share with us the Config tools configuration you are using (the .mex) file with the snippet of code you are using or sample project including the .mex file, we can check if the settings in the configuration are correct.

Regards

Petr Hradsky

Config Tools Team

 

 

3,099件の閲覧回数
DIL98
Contributor II

Hello Petr,

my apologies if the files provided aren´t sufficient, at the moment i am not allowed to share more detailed information

if you need further information please let me know

0 件の賞賛
返信
3,086件の閲覧回数
Petr_H
NXP Employee
NXP Employee

Your post is missing any information about the configurations. You have mentioned that you are using Config tools for the configuration - so how does the configuration of SPI and DMA looks like?

3,062件の閲覧回数
DIL98
Contributor II

My Apologies,

aparently there was an error when I tried to uplaod the .mex file and it seems i cannot upload .mex files, or at least i fail to

i get the error Message "The attachment's lpc54606j256.mex content type (text/html) does not match its file extension and has been removed." when i try to post with a .mex file attached

so i provided screenshots

do you know a work around for the .mex file? i tried changing the file ending to .txt for uplaoding, but that didn´t work

0 件の賞賛
返信
2,954件の閲覧回数
Petr_H
NXP Employee
NXP Employee

Hi,

I'm sorry, it seems there is now more strict policy in attachments formats. Please try to put the .mex into the .zip archive.

Best Regards

Petr Hradsky

2,938件の閲覧回数
DIL98
Contributor II

Hello,

thank you

0 件の賞賛
返信
2,908件の閲覧回数
Petr_H
NXP Employee
NXP Employee

Hi,

we have briefly checked the configuration and there seems to be the following observations:

It's not clear why you have unchecked the RX DMA in the FlexCOM component and you have created TDC structure in the DMA component. It works the way that if you are using DMA mode in the FlexCOM component, you do not have to (and you should not) create the TCD in the DMA.

In the DMA component, the TCD structure contains reference to handle for the destination address. To work properly, It would have to point to the data register of the peripheral. But, as I mentioned above, this is not necessary. The SPI_MasterTransferDMA function of the driver fills channel TCD structure itself inside its code.

So I recommend do check the "Enable Rx DMA channel" in the FlexCOMM0 component:

Petr_H_0-1701880745161.png

and delete the channel TDC in the DMA using the 'X' button:

Petr_H_1-1701880819628.png

So the channels array is  empty, but you can still see the channels occupied by the FlexComm component in the DMA overview table:

Petr_H_2-1701881165894.png

Then, it should work to use the SPI_MasterTransferDMA function as you shown in your snippet posted above.

Please let us know if it was helpful or you still have some issue with making it work.

Best Regards

Petr Hradsky

 

 

2,818件の閲覧回数
DIL98
Contributor II

Hello,

Thank you for your awnser.

I unchecked RX DMA, because there is no incoming data expected.

I implemented a functional form of DMA SPI, that does not have your input, it is attached to this post.

But i tried implementing your input and it was also functional.

I still have one Problem, in both implementations there is one singular SPI Frame transmitted and then nothing more.

I need to configure the DMA SPI in a way, that it continues to write frames. The source of the frames is an array through whitch the DMA module loops. 

Can you help me with that?

0 件の賞賛
返信
3,152件の閲覧回数
Miguel04
NXP TechSupport
NXP TechSupport

Hi @DIL98 

I'm afraid we do not have a document that describes the process to follow for your application.

However, under MCUXpresso LPC54608's SDK, you can find SPI+DMA examples, I recommend you to look into the project and the configuration made with config tools, also, the examples contain comments that describes the process.

The example lpcxpresso54608_spi_dma_b2b_transfer_master seems to be what you are looking for.

Please let me know if this helps you and if I can help you with something else.

Best Regards, Miguel.

3,101件の閲覧回数
DIL98
Contributor II

Hello Miguel,

thank you that has already helped a lot, however i think i fail to correctly handle the DMA interrupt, as i measured one frame beaing transmitted and nothing further happens

 

0 件の賞賛
返信
2,789件の閲覧回数
Petr_H
NXP Employee
NXP Employee

What do you mean by frame? The whole message or just one word  of it? Are you using the SPI_MasterTrasnferDMA with having the datasize specified?

Generally this function just transfers the message and ends, optionally calling the callback. Could you describe more what exactly you would like to achieve?

Regards

Petr Hradsky

2,780件の閲覧回数
DIL98
Contributor II

Hello,

i am sorry if i did not express myself correctly.

With frame i mean a complete SPI transmission consisting of multiple Bits. In this case one transmission is supposed to consist of 16 bits.

in the code there is an array of the type 16bit integer. the DMA controller is supposed to transfer the information stored in an element of the array to the flexcom module. once the flexcom module has completed its SPI transmission, the DMA controller is supposed to transfer the next element in the array to the flexcom module.

when the DMA controller has transferred the last element in the array it shall start transferring the first element again, thus looping back.

The address range of the array does not change.

The DMA controller should not stop transferring the elements, only wait for the flexcom module.

and if possible, I need that without using processor resources after initialization

Again, thank you for your help.

And I apologies if could not communicate my intentions

0 件の賞賛
返信
2,618件の閲覧回数
Petr_H
NXP Employee
NXP Employee

It's Ok, thank you for clarification. So just to be sure, if I rephrase it by my words - you need to keep sending an array of 4800 16-bit integer to the SPI bus in a loop just by DMA. Correct?

One additional detail - how and when would you fill that buffer? Would you like some call back and update the buffer after sending whole block ? I'm asking because, you might need to use two buffers in a ping-pong approach in this situation.

best regards

Petr Hradsky

 

2,608件の閲覧回数
DIL98
Contributor II

Hello,

thank you, for your awnser.

Yes you are correct, sending an array of 4800 16-bit integer to the SPI bus in a loop just by DMA, is my intention.

The buffer will be filled once before BOARD_InitBootPeripherals() is called. The Function DAC_Generate_Lookup() loops through every element of the array and writes to it a calulated 16bit- integer, this is done once after startup.

The buffer is supposed to remain unchanged. So to anwser your question i do not need to update the buffer.

best regards

0 件の賞賛
返信
1,860件の閲覧回数
Petr_H
NXP Employee
NXP Employee

Please find attached a working sample for LPCXpressso 54608 that shows configuration of the DMA, CTIMER and FlexComm SPI via Peripherals tool components where CTimer periodically triggers DMA to perform one SPI frame transfer for each trigger.

The target of the DMA transfer is the SPI FIFO write register which contains both 16-bit data part and configuration part. So, the DMA transfers 32bits at each trigger event from the buffer to the SPI FIFO write register. The buffer needs to be prepared including both data and configuration parts, which is a little disadvantage of this method, as it consumes 4 bytes for each SPI frame (regardles frame length, which can be 1-16 bits).

The TCD (Transfer Control Descriptor) is configured in the DMA component to reload itself after the the length configured in the DMA component is exhausted so the transfer starts from the beginning of the buffer without any software intervention.

The trigger needs to be routed using the inputmux register, this is done in the main code after the peripheral initialization.

Please note that I haven't used DMA mode of the SPI SDK driver is not suited for repeated and linker transfers transfers triggered by hardware. The SPI driver is used only for initial setup with Polling mode.

As this topic is quite complex and there are many possibilities, we are planning to publish more detailed example in the config tools knowledge base

best regards

Petr Hradsky

Config Tools Team