This example shows how you can configure the MPC5744 eTimer block to measure the period of a signal. In addition you should be aware that the eTimer hardware module design includes these distinctive features:
• 6 x 16-bit counters/timers.
• Count up or down.
• Counters are cascadable.
• Enhanced programmable up/down modulo counting.
• Max count rate equals peripheral clock/2 for external clocks.
• Max count rate equals peripheral clock for internal clocks.
• Count once or repeatedly.
• Counters are preloadable.
• Compare registers are preloadable.
• Counters can share available input pins.
• Separate prescaler for each counter.
• Each counter has capture and compare capability.
• Continuous and single shot capture for enhanced speed measurement.
• Counting start can be synchronized across counters.
The application is going to configure the FlexPWM module to generate a PWM signal that changes its frequency between 1000Hz and 10000Hz. The PWM output pins used are A10(J1.5) and A11(J1.7)
The eTimer modele is configured to read the input pin A0(J5.1) and measure its rising edges based on IPBus clock (160Mhz) and a 128 prescaller.
HW Setup:
- Connect a wire between A10(J1.5) to A0(J5.1)
SW Setup:
- Model Based Design Toolbox for MPC5744P v2.0
- Simulink model attached
- Matlab 2015b or newer
- Freemaster 2.0 for data visualization
- Check this video for installation and configuration details:
Verification:
- Build and Download the application to the MPC5744P microprocessor
- Open and connect the Freemaster project attached. You should see:
@10000Hz
@1000Hz
Original Attachment has been moved to: eTimer_measure.mot.zip
Original Attachment has been moved to: Etimer_PWM_measurement.pmp.zip
Original Attachment has been moved to: eTimer_measure.slx.zip
Hi @hjhjhj,
The IPBus is the generic name used for peripheral configuration. The source of the clock for each peripheral might be different. In case of the ETimer the IPBus clock is the MOTC_CLK. Please refer to the MPC5744P Reference manual. T
The maximum frequency of MOTC_CLK is 160Mhz.
In the generated code, the clock setup is made in the mcu_init.c file.
Hope this helps!
Daniel