Some questions about MPC5744 eTimer block

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

Some questions about MPC5744 eTimer block

Jump to solution
1,968 Views
wbj5238
Contributor III

Dear All:

        I have the following questions:

        1. I use this example to calculate the frequency of the pulse signa. When the input pulse signal is less than 10Hz, it can't work properly.  I think it could be the data type of unit16 can not meet the requirements.  How should I solve this problem?

微信截图_20200611091126.png微信截图_20200611091627.png

     2. I observed that this example calculates the frequency every three pulses, but I want to calculate the frequency of each pulse in real time.

@NXP Model-Based Design ToolsModel-Based Design Toolbox for MPC57xx Automotive Microprocessors Version 3.2.0

      

Who can help me?

Thanks.

wangbingjian

1 Solution
1,592 Views
adriantudor
NXP Employee
NXP Employee

Hi Wang, 

1. I use this example to calculate the frequency of the pulse ...

The counter used by Etimer module has 16 bit only, so you can't increase the range of this counter, but the clock source of both modules (PWM and Etimer) used in examples that are you talking, is 80Mhz with the possibility to use a Prescaler (divider) up to 128. So if we use 80Mhz clock source and 128 prescaler and because the Etimer and PWM module has 16 bit, then the lowest frequency that can be used is (80Mhz / 128 / 65535) approx. 9.53Hz.

pastedImage_2.png

pastedImage_4.png

If you modify the Prescaler for Etimer module (because PWM module should do that automatically if you set, let say 100Hz frequency) you should be able to measure 100hz and your duty cycle with the example. But, it is not recommended to design a project to use any hardware, mostly "at the edge" of any parameter. 

The solution to your problem is to modify the clock source of the Etimer module (and of the PWM module if you needed). To do that please take a look here Clock Configuration of MPC5744P using MBD .

Other solution, if you do not want to modify clock source for this module, is to use overflow interrupt for Etimer, and at each overflow interrupt you should add 65535 to a variable until you detect a rising/falling edge and add to that variable the counts from lastest overflow interrupt, the reset your counter variable. Then if you know the Etimer counter frequency you can calculate the pulse time. But keep in mind, if you do that you should use another method to generate your pulse (not PWM due to clock source settings). 

2. I observed that this example calculates the frequency every three pulses ...

I'm not sure why do you say that, but if  you came to this conclusion due to this setting, then you must know that this filter is used to not count some electrical noise, it's a filter parameter that "say" to the Etimer to not count any signal that is not constant for at least 3 clock cycle after the transition. And because the next parameter "Sample Period" is equal to "0", the filter is disabled. So the period of input filtering is set by "Sample period" and how many periods, the signal,  should be constant is set by the "Sample counts". For more info please see MPC5744 reference manual, Etimer module chapter, " Channel n Input Filter Register".

pastedImage_3.png

Best regards,

Adrian.

View solution in original post

7 Replies
1,593 Views
adriantudor
NXP Employee
NXP Employee

Hi Wang, 

1. I use this example to calculate the frequency of the pulse ...

The counter used by Etimer module has 16 bit only, so you can't increase the range of this counter, but the clock source of both modules (PWM and Etimer) used in examples that are you talking, is 80Mhz with the possibility to use a Prescaler (divider) up to 128. So if we use 80Mhz clock source and 128 prescaler and because the Etimer and PWM module has 16 bit, then the lowest frequency that can be used is (80Mhz / 128 / 65535) approx. 9.53Hz.

pastedImage_2.png

pastedImage_4.png

If you modify the Prescaler for Etimer module (because PWM module should do that automatically if you set, let say 100Hz frequency) you should be able to measure 100hz and your duty cycle with the example. But, it is not recommended to design a project to use any hardware, mostly "at the edge" of any parameter. 

The solution to your problem is to modify the clock source of the Etimer module (and of the PWM module if you needed). To do that please take a look here Clock Configuration of MPC5744P using MBD .

Other solution, if you do not want to modify clock source for this module, is to use overflow interrupt for Etimer, and at each overflow interrupt you should add 65535 to a variable until you detect a rising/falling edge and add to that variable the counts from lastest overflow interrupt, the reset your counter variable. Then if you know the Etimer counter frequency you can calculate the pulse time. But keep in mind, if you do that you should use another method to generate your pulse (not PWM due to clock source settings). 

2. I observed that this example calculates the frequency every three pulses ...

I'm not sure why do you say that, but if  you came to this conclusion due to this setting, then you must know that this filter is used to not count some electrical noise, it's a filter parameter that "say" to the Etimer to not count any signal that is not constant for at least 3 clock cycle after the transition. And because the next parameter "Sample Period" is equal to "0", the filter is disabled. So the period of input filtering is set by "Sample period" and how many periods, the signal,  should be constant is set by the "Sample counts". For more info please see MPC5744 reference manual, Etimer module chapter, " Channel n Input Filter Register".

pastedImage_3.png

Best regards,

Adrian.

1,592 Views
wbj5238
Contributor III

      Thank you very much for your reply. I have used PWM as primary input count source to solve the first problem.

      For the second question:

      I make "Sample Period" is equal to "0", So I don't think it's the effect of input filtering. I made a pulse signal of 1Hz and I use etimer module Capture this pulse. Then I use freemaster to observe the relevant variables and I find that CAPT1 FIFO  (  fifo_0_vect(2) and fifo_0_vect(1) )  is updated every 3 seconds(Value increased by 30000). So I say this example calculates the frequency every three pulses. Please tell me calculate the frequency of each pulse. Attachment is the  model.

      Besides, I have a very noisy signal and I wonder if input filtering can help me eliminate noise.

批注 2020-06-11 231801.png

That's the right signal that I want to calculate the frequency .

批注 2020-06-11 231956.png

How should I set input filter parameters?

      We are looking forward to your reply.

      Thank you very much.

0 Kudos
1,592 Views
adriantudor
NXP Employee
NXP Employee

Hi, wang bingjian,

Can you send me your Simulink model ?

Thank you,

Adrian

0 Kudos
1,592 Views
wbj5238
Contributor III

Hello,Have you seen my model? I'm very anxious to know the solution

Looking forward to your reply.

Thank you.

1,592 Views
adriantudor
NXP Employee
NXP Employee

Hi wbj5238@163.com‌,

The problem was on our side.

Please replace the attached .tlc file in your MBDT location {path to your Mathworks addon:} src\mbdtbx_mpc\blocks\etimer .

Waiting for your reply.

Best regards,

Adrian

1,592 Views
wbj5238
Contributor III

Attached is the Simulink model.Connect the PA1 with PA2 to get the primary input count source. Conect the PA0 with PA9.

In this model, I made a variable (test5) to record the time and times of the rising edge catching interrupt.The result shows that the interrupt is triggered every 3 seconds, but the period of input signal is 1 s.微信截图_20200612110850.png

Look forward to your reply.

0 Kudos
1,592 Views
mariuslucianand
NXP Employee
NXP Employee

Hello wbj5238@163.com‌,

Unfortunately, I can't see the images attached. Please attach the model or try reuploading the images.

Waiting for your reply,

Marius

0 Kudos