PWM Signal measurement using ICU-eMIOS channel returning Zero values for both Period & Duty Cycle

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

PWM Signal measurement using ICU-eMIOS channel returning Zero values for both Period & Duty Cycle

1,934 次查看
Jishnu_Bhavadas
Contributor I

Hello Everyone, 

 I was trying to build a project for measuring the Duty cycle and Period of a PWM signal. 

The PWM signal is generated using the MCAL-PWM module by configuring one EMIOS instance under the same. The Port PIN for PWM output is fed into one ICU-EMIOS channel using jumper connection.

Below are the configurations made:

PWM-eMIOS as output channel : 

PWM Channel 0 ;   H/W instance: 0 ;   Channel ID: 1 ;   Mode: OPWFMB , as shown below :

Jishnu_Bhavadas_0-1681134331214.png

Jishnu_Bhavadas_1-1681134382114.png

 

ICU-eMIOS as input channel configuration : 

ICU Channel 0 ;   H/W instance: 1 ;   Channel ID: 10 ;   Mode: IPWM, as shown below :

Jishnu_Bhavadas_2-1681134574669.png   Jishnu_Bhavadas_3-1681134604585.png

 

After all the required Init() function calls, I am using below steps for setting the Duty cycle in PWM output channel and then read from ICU input channel :

Jishnu_Bhavadas_4-1681134730162.png

I have enabled the interrupt handler in ICU module configuration and also enabled "EMIOS1_3_IRQ"(as the input channel is EMIOS1_CH10) in Platform module as well.

But I'm getting Zero values for both Period & Duty Cycle from the Icu_GetDutyCycleValues function. 

While debugging I could see the execution going to the below highlighted step for updating the values as Zero:

Jishnu_Bhavadas_5-1681135163693.png

 

I couldnt figure out what went wrong or any missing configurations.

 

Kindly help me to resolve this issue by your valuable suggestions.

 

Thanks & Regards,

Jishnu

 

 

 

0 项奖励
回复
5 回复数

709 次查看
hangli1
Contributor I

I had a similar problem, the function can jump but the value is still 0, how did you solve it

0 项奖励
回复

1,852 次查看
cuongnguyenphu
NXP Employee
NXP Employee

Hi, Can you debug and check that whether "EMIOS1_3_IRQ" is triggered when start Pwm channel?
As your description, I think that Icu period hasn't updated because Interrupt hasn't entered.
Furthermore, please give me configuration of Interrupt in Platform and Pin configuration also.
And snapshot the code in your application when you Init Platform and enabled "EMIOS1_3_IRQ"

0 项奖励
回复

1,847 次查看
Jishnu_Bhavadas
Contributor I

Hi, 

 Actually I was trying with different input-output pins and below is the one I am currently using for PWM signal calculation:

PWM Output : OPWFMB Mode,  

EMIOS_0_CH_3  = MSCR 130 = GPIO 130 = PTE2  

PWM Input   :  ICU - IPWM Mode

EMIOS_1_CH_1  = MSCR 19  = GPIO 19  = PTA19 

As it is EMIOS1_CH1, I have enabled the interrupt "EMIOS1_5_IRQ" and this interrupt is being triggered as well. In the Design Studio project, I am able to see the capture values in Register A & B and accordingly the "Emios_Icu_Ip_IrqHandler()" is able to calculate some signal values (Values are getting changed when reading in a loop though) and I am able to read it using "Icu_GetDutyCycleValues" api.

Current observation is that :

1) in the second read, it is able to provide both period and duty cycle values (which is same whenever I execute, but able to see a multiplication factor of 2 with what I set in PWM output channel)

2) If I again read the value using Icu_GetDutyCycleValues api, the values are getting changed often. 

Could you please provide clarity on why the signal calculation values are getting changed when I am reading it again. ? 

I tried to bring the same configuration into my baseline project using EB Tresos configuration. Made the same changes as in Design Studio, but then I am not able to see the interrupt trigger and the register A & B are also not showing up any values. 

Could you please suggest me what could be the reason for the Reg A & Reg B capture events are not happening in my integrated project when the same configuration is working with Design Studio project ?

Screenshot showing the register values for the Design studio project :

Jishnu_Bhavadas_0-1681980338588.png

 

Screenshot showing the register values for my integrated project created with EB configuration :

Jishnu_Bhavadas_1-1681980460411.png

 

. Apart from this, I have below queries as well :

1) Is it possible to calculate PWM signal values in ICU-Signal measurement mode with Interrupt disabled ( ie, by disabling corresponding interrupt-EMIOS1_5_IRQn in Platform, disabling the channel ISR-EMIOS1_CH1 in ICU configuration & enabling the flag "IcuSignalMeasureWithoutInterrupt".?

2) When interrupts are disabled, will it still capture values in A & B register properly ? - I tried this in Design Studio project, but I could see the values were not as proper as the case when interrupt enabled. Its giving same values for A & B register in the first read.

3) In the PWM module, how can we calculate the resultant PWM-output signal frequency ?. Saw the below formula from one of the query raised in community,

PWM frequency = CORE_CLK / global pre-scaler / internal pre-scaler / (B1+1)

"B1 is a value written to channel B register."

But as per this calculation, I was not getting the output frequency and is mismatching with the actual generated signal (verified its frequency through oscilloscope).

Below are the values that I set in PWM module:

CORE_CLK = 240MHz | OPWFMB Mode  | 

Global Pre-scaler : 44 (Clock Divider value set in MCL module - EMIOS0_CH23 )

Jishnu_Bhavadas_2-1681981839262.pngJishnu_Bhavadas_3-1681981934140.png

Jishnu_Bhavadas_4-1681982074529.png

As per the formula , we got 340Hz ( 240MHz/ (44*2*(8000+1)), but what I got from the oscilloscope was having 3.67kHz.for 50% duty cycle. (Reg-A value : 4000  &  Reg-B value : 8000).

 

Kindly help me to understand the above mentioned issues and provide resolutions accordingly.

Thanks in advance for your response.

 

Thanks & Regards

Jishnu T B

 

 

0 项奖励
回复

828 次查看
hope_zhou
Contributor I
Having similar issues,I would like to know how you solved this problem。Any follow up from you would be greatly appreciated
0 项奖励
回复

1,059 次查看
KGStafl
Contributor I

Having similar issues regarding reading PWM ICU from a PWM output and also wondering if I can de-select the IcuSignalMeasureWithoutInterrupt button and still get a measurement. Any follow up from NXP would be greatly appreciated.

0 项奖励
回复