How can I synchronize the ADC conversation with the PWM Output Block ?

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

How can I synchronize the ADC conversation with the PWM Output Block ?

Jump to solution
1,999 Views
lethuer
Contributor V
How can I synchronize the ADC conversation with the PWM Output Block, so that the conversation definitly isn't started in the rising or falling edge ?

I want to Trigger the ADC conversation after the PWM Output has a rising edge.

My idea is to set the Output Trigger in the Three_Phase_Output block. But which one ?

I saw this tab in the Three_Phase_Output block:

PWM Output Trigger.PNG

Where can I find the signals PWM X VAL n ?

The selected Output pin I should configure in the ADC config block.

But here after SYNC0 and ADCA Alternate Trigger are selected only this list is displayed.

 

ADC Trigger.png

0 Kudos
1 Solution
1,472 Views
mariuslucianand
NXP Employee
NXP Employee

Hello lethuer‌,

In order to trigger directly the ADC interrupt from the flexPWM block you need to do the following changes:

1. Select output Triggers from the Three_Phase_Output block (for the example attached I chose PWM A VAL3 - falling edge of the A[0] output pin). In order to understand what output triggers you need to choose, please read from the Kinetis RM the Functional Description of the eFlexPWM, Chapter 38.

2. For ADC_Config, you need to choose the XBARA output 12 and then as ADC XBARA Trigger you need to select one according to previously selected trigger (Three_Phase_Output); please read in the same RM, Chapter 27. 

pastedImage_2.jpg

3. Finally you need to disable the  ADC Start conversion block for each channel since the trigger will be done by the PWM. 

pastedImage_3.jpg

I have attached a working example like you asked by computing all the values inside the interrupt. Please be aware of the block execution order by changing the blocks priority if you want a block to be executed before or after another. 

Hope this helps, 

Marius

View solution in original post

0 Kudos
11 Replies
1,472 Views
lethuer
Contributor V

Hi mariuslucianandrei

I still have this question and I try it again.

In the Reference Manual I found this: 

Unbenannt.PNG

Unbenannt.PNG

This is why I configure this in the ADC Config Block:

Unbenannt.PNG

In the PWM Block different values are available.

In center alaigned type these are:

Unbenannt.PNG

So I configure the following in the PWM Block:

Unbenannt.PNG

So in the Reference Manual I found this:

Unbenannt.PNG

--> In my opinion the yellow marked numbers in the picture above are the VAL0, VAL1, VAL2 and VAL3 which you can choose in the PWM Block, correct so far ?

Unbenannt.PNG

--> The second number marked in the picture above should be the TRIG0 or TRIG1 ?

Because I activate VAL0 I would ecpect the connection to XBARA_IN21. (second line in the picture above: PWM0_OUT_TRIG01)

But XBARA_IN21 has PWMA0_TRIG1 as assigned output.

Unbenannt.PNG

So why I have to configure PWMA0_Trigger 0 in the ADC Config Block as ADCA XBARA Trigger ?

0 Kudos
1,472 Views
dumitru-daniel_
NXP Employee
NXP Employee

from lethuer2

Hi Marius Lucian Andrei,

 this really helps ! Thank you so much so far !

discussion branched here: PWM Timing and Signal Generation on MKV4xx microprocessors 

0 Kudos
1,472 Views
lethuer
Contributor V
How can I synchronize the ADC conversation with the PWM Output Block, so that the conversation definitly isn't started in the rising or falling edge ?

Just to make it a little bit clearer...

The modul should work like this:

- ADC converstion should be started by PWM block

- End of ADC conversation should Trigger (Hardware Interrupt) a Subsystem where PWM block is contained

0 Kudos
1,472 Views
lethuer
Contributor V

dumitru-daniel.popamariuslucianandrei

I have still some trouble with this.

Does anybody know a solution ?

The Toolbox includes also a ADC Scan ISR block..

Is it possible to use it like it is in the attached model ?

The ADC conversation still should be started by the PWM block. (This is still missing.)

After the ADC conversation is finished the Subsystem with the contained PWM block should be called.

The PWM block should start a new conversation.

0 Kudos
1,473 Views
mariuslucianand
NXP Employee
NXP Employee

Hello lethuer‌,

In order to trigger directly the ADC interrupt from the flexPWM block you need to do the following changes:

1. Select output Triggers from the Three_Phase_Output block (for the example attached I chose PWM A VAL3 - falling edge of the A[0] output pin). In order to understand what output triggers you need to choose, please read from the Kinetis RM the Functional Description of the eFlexPWM, Chapter 38.

2. For ADC_Config, you need to choose the XBARA output 12 and then as ADC XBARA Trigger you need to select one according to previously selected trigger (Three_Phase_Output); please read in the same RM, Chapter 27. 

pastedImage_2.jpg

3. Finally you need to disable the  ADC Start conversion block for each channel since the trigger will be done by the PWM. 

pastedImage_3.jpg

I have attached a working example like you asked by computing all the values inside the interrupt. Please be aware of the block execution order by changing the blocks priority if you want a block to be executed before or after another. 

Hope this helps, 

Marius

0 Kudos
1,472 Views
lethuer
Contributor V

Hi mariuslucianandrei

I've tried some configurations in order to understand the correct timing.

If I choose VAL3 everything is fine and I can control the signals with my oszilloscope !!

But with Output Trigger VAL0 (for measuring in the middle of PWM_A) the model doesn't run anymore...

I don't know why...?! Do you have an idea ? 

Do I have to set some priorities in this case ?

0 Kudos
1,472 Views
mariuslucianand
NXP Employee
NXP Employee

Hello lethuer2‌,

In order to use VAL0 as Output Trigger you need to select in the ADC_Config  for "ADCA XBARA Trigger" the value "PWM0 Trigger 0" (in the first image of the previous answer).

Hope this helps, 

Marius

1,472 Views
lethuer
Contributor V

Thanks !

That works !

Sorry for the question, but where did you found which VAL is connected to which Trigger ?

0 Kudos
1,472 Views
lethuer
Contributor V

I still didn't found which ADC XBARA Trigger (Trigger 0 or Trigger 1) I have  to choose at which PWM Output VAL.

Can you help me ? 

0 Kudos
1,472 Views
lethuer
Contributor V
0 Kudos
1,472 Views
mariuslucianand
NXP Employee
NXP Employee

Hello lethuer‌,

Sorry for the delay. I understand the desired functionality and I will try to provide a simulink model.

Marius

0 Kudos