Hello, engineer
I want to use the etimer_mpc574x_config module in the MPC5744P's MBD toolbox to generate a 500us interrupt cycle, which is a 200Hz cycle. Then I can execute my code in a timed interrupt, but I don't know how to configure it. Is there a reference design or documentation assistance? Thank you
Solved! Go to Solution.
Hello 260068845@qq.com,
The formula is MOT_CLK/Prescaler/Requested_Frequency = (COMP1+COMP2), where the MOT_CLK is 80MHz.
To get 200Hz, 80Mhz/128/200 = 3125.
By dividing the 3125 result in half for COMPA and COMPB you get on the PA a 50% duty cycle PWM signal. So it doesn't mater which value you set for COMPA and COMPB as long as their sum is 3125 result.
Hope this helps,
Marius
Hello 260068845@qq.com,
So, basically you want to disable the default step interrupt and have an etimer interrupt every 200Hz (btw, 200Hz is 5ms not 500us). An easier approach is to use the PIT timer, the one used for the step timer function.
However, I have attached a model that uses the eTimer to provide an interrupt every 200Hz that toggles the PA1 pin (scope channel 2 - in the image attached). On the PA0 there is the OFLAG output of the eTimer that is changed whenever the COMP1 and COMP2 registers are swapped together. If you need to trigger the signals every 2kHz, you need to compute other values for the Primary counter input source (Prescaler) and the comparator initial values.
Hope this helps,
Marius
Thanks for the reply, 200HZ is indeed 5ms. In addition, I want to know how I can determine the clock frequency through COMP1 and COMP2. If I want to generate a specific clock cycle, is there any calculation formula or technical documentation for reference? Thank you.
Hello 260068845@qq.com,
The formula is MOT_CLK/Prescaler/Requested_Frequency = (COMP1+COMP2), where the MOT_CLK is 80MHz.
To get 200Hz, 80Mhz/128/200 = 3125.
By dividing the 3125 result in half for COMPA and COMPB you get on the PA a 50% duty cycle PWM signal. So it doesn't mater which value you set for COMPA and COMPB as long as their sum is 3125 result.
Hope this helps,
Marius
Hello,Marius
I am a liitle confused to the MOT_CLK, here is 160 max frequency.
How to configure the MOT_CLK to 80Mhz?
best regards
hao
Hello haoxue1027@qq.com,
The clock for the MPC5744P has already been set to 80 MHz. The eTimer, CTU, FlexPWM use the MOTC_CLOCK source which is aready set to 80.
MBDT does not provide a block to change the clocks (mainly because there are some restrictions related to peripherals requirements)so there is a bit more complicated process to do so. If you want to modify the clocks, please have a look not his thread Clock Configuration of MPC5744P using MBD . But you have to be very careful when doing that!
Hope this helps,
Marius
Hello,Marius
The clock for the MPC5744P in the MBD module has already been set to 80 MHz.
So I cannot configurate it in the module, If I want to change it to any value else, I must modify the code.
I got it , Thank you very much.
best regards
hao