
While performing normal conversions on a few standard ADC channel inputs, use the Cross Triggering Unit (CTU) to trigger a conversion from an eMIOS channel event, where the channel is configured as Single Action Input Capture (SAIC).
In this example,
- ADC inputs ANS1 and ANS2 are continuously scanned.
- EMIOS and the CTU are configured so an input signal on eMIOS channel 2 will cause an event that "cross trigger" a conversion for ANS0.
- To generate an input signal, eMIOS channel 3 is configured for OPWM.
- Both channels use eMIOS channel 23 configured as modulus counter for their time base.
Exercise:
- Make the connections shown below. Connect ANS0 to a potentiometer or a known voltage.
- Connect ANS1:2 to other known voltages.
- Verify the eMIOS channel 2 injects an ADC command which reads the pot value.
Program Outcome:
INPUT => OUTPUT ANS0 PB[8] (CTU Inject Mode) (ADC0) => LED1 (ON if Input>=500, else OFF) ANS1 PB[9] (Normal Scan mode)(ADC0) => LED2 (ON if Input>=500, else OFF) ANS2 PB[10] (Normal Scan mode)(ADC0) => LED3 (ON if Input>=500, else OFF) Switch4 PE[3] => LED4 (ON if SW4 Pressed, else OFF) >[To Check Whether Program is executing in Infinite Loop] eMIOS0_3 PA[3] Generates 1KHz with 25% Duty Cycle eMIOS0_2 PA[2] injects conversion at ANS0 (ADC0). (CTU is used)
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:
SIGNAL ADC0_Channel PORT SIU_PAD_CONFIG PACKAGE_PIN(QFP/BGA) 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 eMIOS0[2] - A2 PCR[2]=0503 5 9 F2 eMIOS0[3] - A3 PCR[3]=0600 68 90 K15 Connect Jumper between PA[2] and PA[3]
LED No. => Port No. => Pad No. => Pin No.(144-pin LQFP package) LED1 => PE[4] => PCR[68] => PIN 132 LED2 => PE[5] => PCR[69] => PIN 133 LED3 => PE[6] => PCR[70] => PIN 139 LED4 => PE[7] => PCR[71] => PIN 140 SWITCH No. => Port No. => Pad No. => Pin No.(144-pin LQFP package) SWITCH1 => PE[0] => PCR[64] => PIN 10 SWITCH2 => PE[1] => PCR[65] => PIN 12 SWITCH3 => PE[2] => PCR[66] => PIN 128 SWITCH4 => PE[3] => PCR[67] => PIN 129
Testing:- Output PWM waveform can be observed on DSO.
Downloads:
eMIOS0_CTU_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