MPC5606b, in codewarrior program on ADC gets automatically halted.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MPC5606b, in codewarrior program on ADC gets automatically halted.

1,759 Views
akhilmalik
Contributor II

in codewarrior  when i start the resume button it automatically stops.

Labels (1)
0 Kudos
13 Replies

1,004 Views
akhilmalik
Contributor II

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;

}

0 Kudos

1,004 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

look at this example. It shows, how to use potentiometer on TRK board with ADC. Example is created for MPC5604P, but the code is very similar.

Example MPC5604P ADC setting for scan mode on TRK board

Regards,

Martin

0 Kudos

1,004 Views
akhilmalik
Contributor II

Hi

Oh Thanks Martin

This problem was solved .

Can you please tell me how to connect inbuilt potentiometer of TRK-MPC5606B because i'm not getting my required output!

(or my code was not right)

0 Kudos

1,004 Views
akhilmalik
Contributor II

hi

we are first learning the ADC so were running the following example!!

An ADC reads a potentiometers value. Once a conversion ends the value read is displayed on four LEDs

i have send you the code.

Thank you

0 Kudos

1,004 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

I found the problem. You do not have endless loop in main function.

Regards,

Martin

1,004 Views
akhilmalik
Contributor II

hi

the problem still exits

i have attached the screenshot . u can  see what happens !!!

Screenshot (11).png

0 Kudos

1,004 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

please send me the whole project. I need to investigate deeper.

Regards,

Martin

0 Kudos

1,004 Views
akhilmalik
Contributor II

debugger is USB-ML-PPCNEXUS

0 Kudos

1,004 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

I have tested you code and I found that program stops in function adc_power because of while loop. You are not able to write to ADC_0.MCR register, because you did not enable peripherals during mode transition and ADC is frozen. Replace the code in initModesAndClock by this code:

ME.MER.R = 0x0000001D;          /* Enable DRUN, RUN0, SAFE, RESET modes */                                              

CGM.FMPLL_CR.R = 0x01200100;    /* 8MHz xtal: Set PLL0 to 64 MHz */                                                

ME.RUNPC[0].R = 0x000000FE; /* 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) {}; /* Verify RUN0 is the current mode */

Now, you should be able to execute adc_power function.

Regards,

Martin

0 Kudos

1,004 Views
akhilmalik
Contributor II

hi

micro

TRK-MPC5606B

i use USB cable.

here is the code

#include "MPC5606B.h"

#include"INTCInterrupts.h"

void config_PORT_E(void);

void initModesAndClock(void);

void initPIT();

void PIT_start();

void adc_power(void);

void adc_start(void);

void ADC_EOC_Interrupt(void);

uint32_t LED_state, i;

void main()

{

  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;

  initPIT();

  PIT_start();

adc_power();

  adc_start();

 

   ADC_EOC_Interrupt();

   }

void initModesAndClock(void) {

ME.MER.R = 0x0000001D;

//CGM.FMPLL_CR.R = 0x02400100;

ME.RUN[0].R = 0x001F0074;

ME.RUNPC[0].R = 0x00000010;

ME.MCTL.R = 0x4000A50F;

ME.MCTL.R = 0x40005AF0;

while (ME.GS.B.S_MTRANS) {}

}

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;

SIU.PCR[72].R= 0x0200;

}

void initPIT()

{

PIT.PITMCR.R=0x00000001;

PIT.CH[2].LDVAL.R=8000;

}

void PIT_start()

{

PIT.CH[2].TCTRL.B.TEN=1;

}

void adc_start(void)

{

  ADC_0.MCR.B.WLSIDE=0;

  ADC_0.MCR.B.ADCLKSEL=1;

  ADC_0.MCR.B.NSTART=1;

  //ADC_0.MCR.B.JEDGE=0;

  ADC_0.NCMR0.B.CH0=1;

  ADC_0.MCR.B.MODE=1;

  //ADC_0.JCMR0.B.CH1=1;

  ADC_0.CTR0.R=0x00001205;

  ADC_0.PDEDR.R =0x00000008;

  ADC_0.IMR.B.MSKEOC=1;

  ADC_0.CIMR0.B.CIM0=1;

  //ADC_0.CIMR0.B.CIM1=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)

{

  //if((ADC_0SEL_STATE)&&(ADC.CEOCFR[0].B.EOC_CH0))

  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.EOC = 1;

}

0 Kudos

1,004 Views
akhilmalik
Contributor II

hi

codewarrior IDE

CW_MCU_v10.6_SE.exe

i am working in my college racing team. (TEAM FATEH)

so i need this command of analog to digital conversion to use specific sensors.

here stop means that there is resume icon in codewarrior which we have to press to run our program.

in earlier programs when i press the resume button the program works until i press stop/suspend

but in case of ADC the running program automatically stops. i hope u got my point

no breakpoints from my side

code was almost the the same which is given in the pdf

https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwjSjbqC-r...

and i don't know about the debugger(if important please how tell from where i can check it)

THANK YOU

0 Kudos

1,004 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

please share your code. From your description, I am not able to tell you where is the problem. I also need to know, what debugger probe you use and also please specify the board with micro. Is it TRK-MPC5604B? Do you program the micro via USB cable or via JTAG?

Please write me back and share your project.

Regards,

Martin

0 Kudos

1,004 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

to solve your problem I need more information, because you description of the issue is too general. So please clarify me the following points:

- which CodeWarrior you use?

- do you have your own project or some example project from community? If you have your own project, is it possible to share?

- what does it mean that "it stops"? program stops? or ADC conversion?

- do you use some breakpoints in your code?

- what debugger you use? (PE Micro, Lauterbach, some other...)

Regards,

Martin

0 Kudos