
- We will be testing eMIOS by generating 6 PWM output simultaneously and will be changing its duty cycle in run time using Potentiometer which is connected to ADC0 input. At the same time, ADC input is indicated using 4 LEDs as follows:
Program Outcome:
20KHz PWM at eMIOS0_1 => PA[1], eMIOS0_2 => PA[2], eMIOS0_3 => PA[3], eMIOS0_4 => PA[4], eMIOS0_5 => PA[5], eMIOS0_6 => PA[6]. Initial Duty_Cycle = 10% Input(Analog) => Output PB[8] (ADC0_S0) => (eMIOS0_1 to eMIOS0_6) & [LED1 LED2 LED3 LED4] ADC0 = [0 to 1023] => Duty_Cycle = [0% to 98%] & LED Indication Input Pot value (Digital) => [LED1 LED2 LED3 LED4] Output 0 to 200 => ON OFF OFF OFF 201 to 500 => ON ON OFF OFF 501 to 800 => ON ON ON OFF 801 to 1023 => ON ON ON ON
Changelog:
26/03/2016: Bug:Phase lag of 1uSec is present between (eMIOS0_1,2,3) and (eMIOS0_4,5,6) 26/03/2016: Bug:Phase lag of 1uSec is present between (eMIOS0_1,2,3) and (eMIOS0_4,5,6) 01/04/2016: Phase lag removed. [clear the GTBE bit at beginning of Init_eMIOS() and set it at the end of the Init_eMIOS().] 18/04/2016: Remove PCTL[32] & PCTL[68] command from InitModesAndClks function to run eMIOS and ADC together
Connections:
eMIOS No. => Port No. => Pad No. => Pin No.(144-pin LQFP package) eMIOS0_1 => PA[1] => PCR[1] => PIN 11 eMIOS0_2 => PA[2] => PCR[2] => PIN 9 eMIOS0_3 => PA[3] => PCR[3] => PIN 90 eMIOS0_4 => PA[4] => PCR[4] => PIN 43 eMIOS0_5 => PA[5] => PCR[5] => PIN 118 eMIOS0_6 => PA[6] => PCR[6] => PIN 119 SIGNAL ADC0_Channel PORT SIU_PAD_CONFIG PACKAGE_PIN (100 144 176) ANS0 => 32 B8 PCR[24]=2000 39 53 R9 ANS1 => 33 B9 PCR[25]=2000 38 52 T9 ANS2 => 34 B10 PCR[26]=2000 40 54 P9 Potentiometer is connected to ANS0 (B8) for this program.
Calculations:
Frequency Calculation of PWM: For "x" Hz Frequency, B_VAL = 1/[(x)*10^-6] Duty Cycle Calculation of PWM: For "y" % Duty Cycle, A_VAL = (y)*100/(x)
Testing:- Output PWM waveform can be observed on DSO.
- Potentiometer input can be seen approximately on 4 LEDs in discrete range.
Exercise:
Make the connections shown below:
- Connect DSO probe +ve terminal to eMIOS0_1 PA[1] and DSO prob gnd to the gnd of the TRK-MPC5606B board.
- Similarly, Connect remaining eMIOS0 and test it.
Downloads:
eMIOS0_ADC0_TRK-MPC5606B_APDaga
Click here to see more codes for Freescale/NXP MPC56xx Family.
Feel free to ask doubts in the comment section. I will try my best to solve it.
If you find this helpful by any mean like, comment and share the post.
This is the simplest way to encourage me to keep doing such work.
Thanks and Regards,
-Akshay P. Daga