K64 DMA application question

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

K64 DMA application question

Jump to solution
1,015 Views
cuizhuangping
Contributor I

Hi,everyone, I found a question when using ADC. I set four DMA chanels, the first used to transfer the ADC chanel for ADC0, the second used to tranfer data after the finishing of ADC0 convert. The third used to transfer the ADC chanel for ADC1, the fourth used to tranfer data after the finishing of ADC1 convert. I want to get the ADC0 data and ADC1 data at the same time to calculte the angle of the two data series, so i set the same  soure request for DMA1 and DMA3,both PDB request. However, I found one of the datas order is wrong when the two ADC works using the same PDB?

Labels (1)
0 Kudos
1 Solution
754 Views
EarlOrlando
Senior Contributor II

Hello,

In the K64 Reference Manual​, in the section 21.3.1 you can see a note which says that you only can use one channel at the same time:

pastedImage_1.png

As I understood you want to trigger the DMA channels 1 and 3 through the PDB and you want to trigger the ADC trough the DMA channels (software trigger). As the reference manual says, you can not configure the CH1 and CH2 to start the ADC through the software trigger at the same time but you can configure the hardware trigger in both ADC instances so you will not need the DMA.

Best regards,

Earl.

View solution in original post

0 Kudos
8 Replies
755 Views
EarlOrlando
Senior Contributor II

Hello,

In the K64 Reference Manual​, in the section 21.3.1 you can see a note which says that you only can use one channel at the same time:

pastedImage_1.png

As I understood you want to trigger the DMA channels 1 and 3 through the PDB and you want to trigger the ADC trough the DMA channels (software trigger). As the reference manual says, you can not configure the CH1 and CH2 to start the ADC through the software trigger at the same time but you can configure the hardware trigger in both ADC instances so you will not need the DMA.

Best regards,

Earl.

0 Kudos
754 Views
cuizhuangping
Contributor I

Thanks for your answer, but configure the hardware trigger in both ADC instances will introduce another question. Here,I want to collect Ua,Ub,Uc,Ia,Ib and Ic, The collection of Ua,Ub and Uc finished by ADC0. ADC1 finish the others, so the ADC chanels must be transfered at the same time. I cannot transfer the chanels when using the hardware trigger by PDB? If I set two different request soure for DMA1 and DMA3,maybe FTM0 and FTM1,can it work ok?

0 Kudos
754 Views
EarlOrlando
Senior Contributor II

Hi,

You can trigger both ADC instances at the same time and you can avoid that the ADC triggers the DMA because that could cause errors. Maybe read the ADC values in an interrupt is a good solution. The value converted by the ADC is the one present at the moment of the conversion, it does not matter if you read those values at different time.

Regards,

Earl.

0 Kudos
754 Views
cuizhuangping
Contributor I

Hi,

   Read the ADC values in an interrupt maybe a good solution in the low speed colletion. The CPU will cost a lot If I collect the data at a very high speed,for example, each at a speed of 300k for ADC0 and ADC1. The CPU almost have no consumption when using DMA method. Here ,I want to use two PITs to periodic trigger the DMA1 and DMA3. The time of DMA1 and DMA3 seems not so certain.

0 Kudos
754 Views
EarlOrlando
Senior Contributor II

Hello Cui,

I have another solution. Trigger the ADC0 and the ADC1 with the PIT, then trigger a DMA channel with one ADC and finally trigger the other DMA channel with the first one (channel linking).

Best regards,

Earl.

0 Kudos
754 Views
cuizhuangping
Contributor I

Hi Sanchez:

    Thank you for the advice. But I think you have made a mistake, I want change the chanels  for ADC0 and ADC1 at the same time, for example, the ADC0 get Ia,Ib and Ic,ADC1 get the Ua,Ub and Uc, I want the ADC0 and ADC1 change chanels at the same time, so I can get Ia,Ua or Ib,Ub or Ic,Uc at the same time. I cannot change the chanels if I use Hardware trigger for ADCs.

0 Kudos
754 Views
EarlOrlando
Senior Contributor II

Hello Cui,

You could do this with two other DMA linked channels. When the ADC results are copied through the first two DMA channels then you can copy the two new ADC channels to the register SC1n[ADCH] through the other two DMA channels.

Best regards,

Earl.

0 Kudos
754 Views
cuizhuangping
Contributor I

Hi Sanchez:

     That's fantastic. DMA chanel linking sounds good, I will try this method: PDB or PIT trigger ADC0 and ADC1 at the same time, Then the finishing of ADC0 and ADC1 trigger DMA1 and DMA2. Then finishing of DMA1 and DMA2 will trigger DMA3 and DMA4, that change the ADC chanels.  I'll tell you the result after trying.

0 Kudos