S12ZVC ADC converting error

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

S12ZVC ADC converting error

1,851 Views
jtpark
Contributor IV

Hello,

 

I tested S12ZVC in code warrior 10.6.

When I was connect to multilink, It is good to convert ADC but I was removed a multilink, It is not work.

So I checked when is not work in run mode.

Please see the below code.

 

#define ADC_CSL_AN8 (CMD_SEL(0)+ INTFLG_SEL(1)+ VRH_SEL(1)+ VRL_SEL(1)+ CH_SEL(0x18))
#define ADC_CSL_AN9 (CMD_SEL(3)+ INTFLG_SEL(2)+ VRH_SEL(1)+ VRL_SEL(1)+ CH_SEL(0x19))
#define CMD_SEL(x) ((unsigned long)((x)&0x03)<<30)
#define INTFLG_SEL(x) ((unsigned long)((x)&0x0F)<<24)
#define VRH_SEL(x) ((unsigned long)((x)&0x01)<<23)
#define VRL_SEL(x) ((unsigned long)((x)&0x01)<<22)
#define CH_SEL(x) ((unsigned long)((x)&0x3F)<<16)
#define SMP(x) ((unsigned long)((x)&0x1F)<<11)

 

unsigned long u32_aux_address;
unsigned long adc0_cmdlist[8] @0x002000;
unsigned int adc0_results[8] @0x002100;

 

void main(void) {

DisableInterrupts ;

CPMUCLKS_PLLSEL = 1; //FBUS = FPLL/2. FBUS = 32MHz,
CPMUREFDIV_REFFRQ = 1; //Reference clock between 2MHZ and 6MHZ.
CPMUREFDIV_REFDIV = 0x1; //FREF=8/(1+1) = 4MHZ
CPMUSYNR_VCOFRQ = 0x1; //FVCO is between 48MHZ and 80MHZ
CPMUSYNR_SYNDIV = 0x7; //FVCO = 2xFREFx(SYNDIV+1) = FVCO = 2x4x(7+1) = 64MHZ
CPMUPOSTDIV_POSTDIV = 0x0; //FPLL = FVCO/(POSTDIV+1). FPLL = 64MHZ/(0+1) FPLL = 64MHz
CPMUOSC_OSCE = 1; //External oscillator enable. 8MHZ. FREF=FOSC/(REFDIV+1)
while(!CPMUIFLG_LOCK){} // Wait for LOCK.
CPMUIFLG = 0xFF; // clear CMPMU int flags - not needed but good practice

 

DDRP = 0x0F; /* LEDs as outputs */
adc0_cmdlist[0] = ADC_CSL_AN8;
adc0_cmdlist[1] = ADC_CSL_AN9;

 

/* Configure ADC0 control */
ADC0CTL_0 = 0x0DU; /* Dual-access mode(ACC_CFG), Trigger mode(MOD_CFG) */
ADC0CTL_1 = 0x00U; /* Single CSL & RVL buffers(CSL_BMOD, RVL_BMOD), Normal access, No Auto-Restart after exit from STOP */
ADC0STS = 0x00U; /* Select CSL 0 and RVL 0 */
ADC0TIM = 0x01U; /* fADCCLK = fBUS/(2*(PRS+1)) = 32Mhz/(2*(1+1)) = 8Mhz */

/*** ADC0CBP - ADC0 Command Base Pointer Register configuration ***/
u32_aux_address = (unsigned long) &adc0_cmdlist[0U];
ADC0CBP_0 = (unsigned char) (u32_aux_address >> 16U);
ADC0CBP_1 = (unsigned char) (u32_aux_address >> 8U);
ADC0CBP_2 = (unsigned char) (u32_aux_address);

/*** ADC0RBP - ADC0 Result Base Pointer Register configuration ***/
u32_aux_address = (unsigned long) &adc0_results[0U];
ADC0RBP_0 = (unsigned char) (u32_aux_address >> 16U);
ADC0RBP_1 = (unsigned char) (u32_aux_address >> 8U);
ADC0RBP_2 = (unsigned char) (u32_aux_address);

/*** ADC0FMT - ADC0 Format Register ***/
ADC0FMT = 0x82U; /* 10-bit resolution, right justified */

ADC0CONIF = ADC0CONIF; /* ADC interrupt complete flag clear */

BATE = 0x08U; /* BATS VSUP ADC Connection Enable - Internal 4 */

/* Start conversion -- ADC0 */
ADC0CTL_0_ADC_EN = 1U; /* Enable the ADC */

ADC0CONIF = ADC0CONIF; /* clear flag */
ADC0FLWCTL_RSTA = 1U; /* Trigger a Restart event */

while( ADC0CONIF_EOL_IF==0U ) {
DDRP_DDRP0 = 1 ; // D13           ------------->If it was not work, It is stop in this line.
} /* wait for EOL_IF set */

ADC0CONIF = ADC0CONIF; /* clear flag */

EnableInterrupts;
for(;;) {
__RESET_WATCHDOG(); /* feeds the dog */
DDRP_DDRP4 = 1 ; // D15
} /* loop forever */
}

 

If it is good to work, turn on the D13, D15.(connected multilink)

but when it was not operate, only turn on D13. (removed multilink)

How to solve this issue?

Would you please provide to me that why happen this situation?

 

Thanks.

Labels (1)
4 Replies

1,211 Views
jtpark
Contributor IV

Dear Daniel,

I attached project file.

Would you please test attached file?

My project is always stop at that line without multilink.

PTP_PTP6 = 1U;
ADC0CONIF = ADC0CONIF; /* clear flag */
ADC0FLWCTL_RSTA = 1U; /* Trigger a Restart event */


while( ADC0CONIF_EOL_IF==0U ) { /*Nothing*/ } /* wait for EOL_IF set */  --> Stop position.

Would you please let me know how to solve this issue?

Thanks.

0 Kudos
Reply

1,211 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi

Indeed, the project you attached didn’t run stand alone.

If this happens, connect the debugger back and debug it in Attach session type.

You will then see registers and that helps.

For instance, in this case EOL_EIF error flag was set and thus the ADC operation stopped.

 

The problem was caused by memory allocation.

Please use  __attribute__ ((aligned (4))) instead of @0x002000

as you can see in the in the project attached.

Regards

Daniel

1,211 Views
jtpark
Contributor IV

Dear Daniel,

I have solve this issue.

Thank you for your support.

But I would like to know how can I setting a memory map .

Would you provide to me guide file of memory map?

Thanks.

0 Kudos
Reply

1,211 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi

 

I have tested your code in CW10.7 with 12ZVC and it works fine.

The project is attached so you can run it and check linker file etc.

 

Regards

 

Dan

0 Kudos
Reply