i wanted the output that led must be off in the order mentioned in code by changing the value of potentiometer
but the led are getting dim but not off!!!
here is the code
#include "MPC5606B.h"
#include"INTCInterrupts.h"
void config_PORT_E(void);
void initModesAndClock(void);
void adc_power(void);
void adc_start(void);
void ADC_EOC_Interrupt(void);
uint32_t LED_state, i;
void main()
{
for(;;)
{initModesAndClock();
config_PORT_E();
SIU.GPDO[68].B.PDO = 0;
SIU.GPDO[69].B.PDO = 0;
SIU.GPDO[70].B.PDO = 0;
SIU.GPDO[71].B.PDO = 0;
adc_power();
adc_start();
ADC_EOC_Interrupt();
} }
void initModesAndClock(void) {
ME.MER.R = 0x0000001D; /* Enable DRUN, RUN0, SAFE, RESET modes */
ME.RUNPC[0].R = 0x00000010; /* enable peripherals run in all modes */
ME.RUN[0].R = 0x001F0074; /* RUN0 cfg: IRCON,OSC0ON,PLL0ON,syclk=PLL */
/* Mode Transition to enter RUN0 mode: */
ME.MCTL.R = 0x40005AF0; /* Enter RUN0 Mode & Key */
ME.MCTL.R = 0x4000A50F; /* Enter RUN0 Mode & Inverted Key */
while (ME.GS.B.S_MTRANS) {} ; /* Wait for mode transition to complete */
while(ME.GS.B.S_CURRENTMODE != 4) {};
}
void config_PORT_E(void)
{
SIU.PCR[68].R = 0x0200;
SIU.PCR[20].R= 0x2100;
SIU.PCR[69].R = 0x0200;
SIU.PCR[70].R = 0x0200;
SIU.PCR[71].R = 0x0200;
SIU.PCR[64].R = 0x0100;
SIU.PCR[65].R= 0x0100;
}
void adc_start(void)
{
ADC_0.MCR.B.WLSIDE=0;
ADC_0.MCR.B.ADCLKSEL=1;
ADC_0.MCR.B.NSTART=1;
ADC_0.NCMR0.B.CH0=1;
ADC_0.MCR.B.MODE=1;
ADC_0.CTR0.R=0x00001205;
ADC_0.PDEDR.R =0x00000008;
ADC_0.IMR.B.MSKEOC=1;
ADC_0.CIMR0.B.CIM0=1;
}
void adc_power(void)
{
ADC_0.MCR.B.PWDN=0;
while(ADC_0.MSR.R == 0x00000001)
{};
}
void ADC_EOC_Interrupt(void)
{
static uint32_t result16;
if(ADC_0.ISR.B.EOC)
{
while(ADC_0.CDR[0].B.VALID !=1)
{};
result16 = ADC_0.CDR[0].B.CDATA;
}
result16=result16/204;
switch(result16)
{
case 0: SIU.GPDO[68].B.PDO = 1;
break;
case 1:SIU.GPDO[69].B.PDO = 1;
break;
case 2: SIU.GPDO[70].B.PDO = 1;
break;
case 3: SIU.GPDO[71].B.PDO = 1;
break;
case 4: SIU.GPDO[70].B.PDO = 1;
SIU.GPDO[71].B.PDO = 1;
break;
default:
break;
}
ADC_0.ISR.B.JEOC = 1;
}