Announcements

Equip yourself to optimize PSoc4 MCUs for Evs at the EV Webinar. Click here to register.

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

PSoC™ 4 Forum Discussions

Sanyika
Level 2
Level 2
10 sign-ins 5 replies posted 5 questions asked

Hello,
I'm using a DMA connected to a RX SPI component.
The descriptor 0 capture just the first byte (just send it to trash)

I use this block to read 150 bytes from a SPI accelerometer
Sometime I need to change some value on the register or read it, so I send just 2 bytes (reg.address and 0x00)

My question is : how to reset the DMA index to restart it as it was initialized ?
I want to reset it before to send my 2 bytes, so like that I can read the data always at the same address.
If I don't reset, I can not to know which address was used for the data (only when I send 2 bytes)
I already try to use the Status of the DMA to get the current index position, but it's doesn't work properly when it was the first data or the last data captured by the DMA.
Thank you
Alex

AlST_2955341_0-1616144624604.png

 

0 Likes
1 Solution
BragadeeshV
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hi @Sanyika ,

My understanding is , when you say "To configure my SPI device", I assume you are sending the two bytes in SPI_mosi_m_Write(). This means you are not using the TxDma_Spi to transfer the two bytes. Can you disable the RxDma_SPI when you are transmitting the two bytes and simply use RX FIFO not empty interrupt to retrieve the two bytes. If you disable the RxDma_SPI, then the dest address of the receiver end is not incremented. And later when you want to resume the 151 byte transaction, you can reenable the Rx DMA. 

Can you please let us know if this works for you?

Regards,
Bragadeesh

View solution in original post

5 Replies
BragadeeshV
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hi @Sanyika ,

Can you please let us know what you mean by resetting DMA index? Do you want to restart the DMA again from Descriptor 0? 

Is the PSoC using SPI master or slave? 

How are you sending the two bytes? Are you using another DMA to transfer data to TX FIFO?

We are finding it difficult to understand your question. We would appreciate if you could share your project or share with us some kind of a firmware flow diagram that would help us understand your query better. 

In general, if you want to restart a DMA (assuming the channel was previously disabled), set the descriptor 0 usingl DMA_SetNextDescriptor() and then enable the channel using DMA_ChEnable().

Regards,
Bragadeesh
0 Likes
Sanyika
Level 2
Level 2
10 sign-ins 5 replies posted 5 questions asked

Sanyika_0-1616492694140.png

Hello Bragadeesh,

oups sorry for my English,
I use 2 DMA connected to the SPI.
- TX DMA is configured with 151 bytes (one descriptor)

-RX DMA : dec0 1 byte; desc1 150 bytes

The classic operation is to read 150 byte from my SPI device, so I send the register on the first TX byte (with DMA) and when the RX dma is trigger I read the data.

To configure my SPI device, I send directly byte with the SPI_mosi_m_Write() command

When RX DMA get 2 byte, it increase the dest. address, so my question is how to reset the DMA like it was initialized

0 Likes
BragadeeshV
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hi @Sanyika ,

My understanding is , when you say "To configure my SPI device", I assume you are sending the two bytes in SPI_mosi_m_Write(). This means you are not using the TxDma_Spi to transfer the two bytes. Can you disable the RxDma_SPI when you are transmitting the two bytes and simply use RX FIFO not empty interrupt to retrieve the two bytes. If you disable the RxDma_SPI, then the dest address of the receiver end is not incremented. And later when you want to resume the 151 byte transaction, you can reenable the Rx DMA. 

Can you please let us know if this works for you?

Regards,
Bragadeesh
Sanyika
Level 2
Level 2
10 sign-ins 5 replies posted 5 questions asked

Ok thank you, I'll test it this week

0 Likes
Sanyika
Level 2
Level 2
10 sign-ins 5 replies posted 5 questions asked

Thank you very much,
It's works well, and it solves an another issue.
Thank you Bragadeesh

Have a good day
Alexandre

0 Likes