MPC5606B error

cancel
Showing results for 
Search instead for 
Did you mean: 

MPC5606B error

471 Views
khaleadpark
Contributor II

Hi.  I have TRK-MPC 5606B board.

I have a problem.

 

Error:

Illigal operands 'volatile union' [ 'unsigned char'

 

Code:

 

void vfnInit_normalconversion_adc(unit8_t u8ChannelType, unit32_t u32Channel)

{

 

ADC_0.CTR0[u8ChannelType].R = 0x00008606;

 

.......

 

}

 

[u8ChannelType] → error

 

Please help me.  Please.....

 

Thank you.

 

Khaled

Labels (1)
7 Replies

48 Views
iansmusical
Contributor V

Hi Khalead,

I'm not sure if this lines makes sense?

  ADC_0.CTR0[u8ChannelType].R = 0x00008606;

From the reference manual there are 3 CTR registers, were you meaning?

  ADC_0.CTR[u8ChannelType].R = 0x00008606;

Can you tell us what exactly you are trying to achieve with that line?

Thanks,

Ian

0 Kudos

48 Views
khaleadpark
Contributor II

Freescale Cup car-related code.

0 Kudos

48 Views
khaleadpark
Contributor II

/**

\brief Initialize Adc in scan mode, Configure Adc clock to 32 MHz, set an Adc Channel from a channel type

as a Normal Conversion, and start conversions by settin NSTART to 1.

\param u8ChannelType: defined in Driver_MPC5604B.h as ADC_CHANNEL_TYPE_tag

u32Channel: defined in Driver_MPC5604B.h as ADC_CHANNEL_tag

\return nule

*/

Driver_MPC5604B.h = D_MPC5606B.h

0 Kudos

48 Views
iansmusical
Contributor V

Hi Khalead,

Thanks for all the information but I think the error:

  Illegal operands 'volatile union' [ 'unsigned char'

is trying to say that the CTR0/1/2 registers can't be accessed as an array with u8ChannelType as the index. In fact the text:

  /* Note the following CTR registers are NOT implemented as an array to */

  /*  try and maintain some concistency through the header file          */

  /*  (The registers are however identical)                              */

kind of backs this up!

I work with the PPC MPC55xx, 56xx and 57xx daily but I don't use the Freescale header file with all the registers defined, so I could be wrong with the interpretation of the error you are seeing!

I'll check my implementation when I'm at work on Monday :-)

Thanks,

Ian

48 Views
iansmusical
Contributor V

Hi Khalead,

This is the implementation I use:

#define ADC_0_CTR    (*(volatile unsigned long *) 0x<register address>UL)

And then perhaps something like:

int index;

volatile unsigned long *adc_ctr = &ADC_0_CTR;

for (index = 0; index < 3; index++) {

  adc_ctr[index] = <value>;

}

Hope it helps :-)

Thanks,

Ian

0 Kudos

48 Views
khaleadpark
Contributor II

Hi Ian ~

I use a code wrrior 'CW for MCU v10.5'

D_MPC5606.h :

#define CTU_CHANNEL_ANS5 21 /*Adc Channel 37*/

#define CTU_CHANNEL_ANS6 22 /*Adc Channel 38*/

#define CTU_CHANNEL_ANS7 23 /*Adc Channel 39*/

/* Adc channel types values for NCMR and CTR Channel Type parameter */

#define ADC_0_PRECISION_CHANNEL 0 /* Precision channel */

#define ADC_0_EXTENDEDINT_CHANNEL 1 /* Extended Internal channel */

#define ADC_0_EXTERNAL_CHANNEL 2 /* External channel */

/* Adc channel values for NCMR or JCMR Channel Register */

/* Values for Precision Channels */

#define ADC_0_CHANNEL_ANP0 0x00000001 /*Adc Channel 0*/

#define ADC_0_CHANNEL_ANP1 0x00000002 /*Adc Channel 1*/

#define ADC_0_CHANNEL_ANP2 0x00000004 /*Adc Channel 2*/

#define ADC_0_CHANNEL_ANP3 0x00000008 /*Adc Channel 3*/

#define ADC_0_CHANNEL_ANP4 0x00000010 /*Adc Channel 4*/

#define ADC_0_CHANNEL_ANP5 0x00000020 /*Adc Channel 5*/

#define ADC_0_CHANNEL_ANP6 0x00000040 /*Adc Channel 6*/

#define ADC_0_CHANNEL_ANP7 0x00000080 /*Adc Channel 7*/

#define ADC_0_CHANNEL_ANP8 0x00000100 /*Adc Channel 8*/

#define ADC_0_CHANNEL_ANP9 0x00000200 /*Adc Channel 9*/

#define ADC_0_CHANNEL_ANP10 0x00000400 /*Adc Channel 10*/

#define ADC_0_CHANNEL_ANP11 0x00000800 /*Adc Channel 11*/

#define ADC_0_CHANNEL_ANP12 0x00001000 /*Adc Channel 12*/

#define ADC_0_CHANNEL_ANP13 0x00002000 /*Adc Channel 13*/

#define ADC_0_CHANNEL_ANP14 0x00004000 /*Adc Channel 14*/

#define ADC_0_CHANNEL_ANP15 0x00008000 /*Adc Channel 15*/

/* Values fo Extended Internal Channels */

#define ADC_0_CHANNEL_ANS0 0x00000001 /*Adc Channel 32*/

#define ADC_0_CHANNEL_ANS1 0x00000002 /*Adc Channel 33*/

#define ADC_0_CHANNEL_ANS2 0x00000004 /*Adc Channel 34*/

#define ADC_0_CHANNEL_ANS3 0x00000008 /*Adc Channel 35*/

#define ADC_0_CHANNEL_ANS4 0x00000010 /*Adc Channel 36*/

#define ADC_0_CHANNEL_ANS5 0x00000020 /*Adc Channel 37*/

#define ADC_0_CHANNEL_ANS6 0x00000040 /*Adc Channel 38*/

#define ADC_0_CHANNEL_ANS7 0x00000080 /*Adc Channel 39*/

/* PCR for GPIO */

#define GPIO_PIN_A0 0

#define GPIO_PIN_A1 1

#define GPIO_PIN_A2 2

#define GPIO_PIN_A3 3

#define GPIO_PIN_A4 4

#define GPIO_PIN_A5 5

#define GPIO_PIN_A6 6

#define GPIO_PIN_A7 7

#define GPIO_PIN_A8 8

#define GPIO_PIN_A9 9

#define GPIO_PIN_A10 10

#define GPIO_PIN_D0 48

#define GPIO_PIN_D1 49

#define GPIO_PIN_D2 50

#define GPIO_PIN_D3 51

#define GPIO_PIN_D4 52

#define GPIO_PIN_D5 53

#define GPIO_PIN_D6 54

#define GPIO_PIN_E0 64

#define GPIO_PIN_E1 65

#define GPIO_PIN_E2 66

#define GPIO_PIN_E3 67

#define GPIO_PIN_E4 68

#define GPIO_PIN_E5 69

#define GPIO_PIN_E6 70

#define GPIO_PIN_E7 71

#define GPIO_PIN_G10 106

D_ADC.c :

#include "D_MPC5606B.h"

#include "D_ADC.h"

/** Set an Adc channel as normal conversion channel **/

void vfnInit_NormalConversion_Adc(uint8_t u8ChannelType, uint32_t u32Channel)

{

ADC_0.MCR.R = 0x20000000;/* Initialize ADC0 for scan mode and allow cross triggering */

ADC_0.CTR0[u8ChannelType].R = 0x00008606; /* Conversion times for 32MHz ADClock */ ---> error : Illegal operands 'volatile union' [ 'unsigned char'

ADC_0.MCR.B.ADCLKSEL = 0;

//ADC_0.NCMR0[u8ChannelType].R = ADC_0.NCMR0[u8ChannelType].R | u32Channel; /* Set channel mask as normal conversion mask */

ADC_0.NCMR0[u8ChannelType].R = 0; ------------> error : Illegal operands 'volatile union' [ 'unsigned char'

ADC_0.NCMR0[u8ChannelType].R = ADC_0.NCMR0[u8ChannelType].R | u32Channel; --> error : Illegal operands 'volatile union' [ 'unsigned char'

ADC_0.MCR.B.NSTART=1; /* Start Normal Conversion */

}

D_ADC.h :

#include "D_MPC5606B.h"

#include "typedefs.h"

/**

\brief Initialize Adc in scan mode, Configure Adc clock to 32 MHz, set an Adc Channel from a channel type

as a Normal Conversion, and start conversions by settin NSTART to 1.

\param u8ChannelType: defined in Driver_MPC5604B.h as ADC_CHANNEL_TYPE_tag

u32Channel: defined in Driver_MPC5604B.h as ADC_CHANNEL_tag

\return nule

*/

void vfnInit_NormalConversion_Adc(uint8_t u8ChannelType,uint32_t u32Channel);

MPC5606B.h :

/* Note the following CTR registers are NOT implemented as an array to */

/* try and maintain some concistency through the header file */

/* (The registers are however identical) */

union { /* ADC0 Conversion Timing 0 (Base+0x0094) */

vuint32_t R; /* (precision channels) */

struct {

vuint32_t:16;

vuint32_t INPLATCH:1;

vuint32_t:1;

vuint32_t OFFSHIFT:2;

vuint32_t:1;

vuint32_t INPCMP:2;

vuint32_t:1;

vuint32_t INPSAMP:8;

} B;

} CTR0;

union { /* ADC0 Conversion Timing 1 (Base+0x0098) */

vuint32_t R; /* (standard channels) */

struct {

vuint32_t:16;

vuint32_t INPLATCH:1;

vuint32_t:4;

vuint32_t INPCMP:2;

vuint32_t:1;

vuint32_t INPSAMP:8;

} B;

} CTR1;

union { /* ADC0 Conversion Timing 2 (Base+0x009C) */

vuint32_t R; /* (Ext multiplexed channels) */

struct {

vuint32_t:16;

vuint32_t INPLATCH:1;

vuint32_t:4;

vuint32_t INPCMP:2;

vuint32_t:1;

vuint32_t INPSAMP:8;

} B;

} CTR2;

vuint8_t ADC0_reserved5[4]; /* Reserved 4 bytes (Base+0x00A0-0x00A3) */

union { /* ADC0 Normal Conversion Mask 0 (Base+0x00A4) */

vuint32_t R; /* (precision channels) */

struct {

vuint32_t :16;

vuint32_t CH15:1;

vuint32_t CH14:1;

vuint32_t CH13:1;

vuint32_t CH12:1;

vuint32_t CH11:1;

vuint32_t CH10:1;

vuint32_t CH9:1;

vuint32_t CH8:1;

vuint32_t CH7:1;

vuint32_t CH6:1;

vuint32_t CH5:1;

vuint32_t CH4:1;

vuint32_t CH3:1;

vuint32_t CH2:1;

vuint32_t CH1:1;

vuint32_t CH0:1;

} B;

} NCMR0;

union { /* ADC0 Normal Conversion Mask 1 (Base+0x00A8) */

vuint32_t R; /* (standard channels) */

struct {

vuint32_t :4;

vuint32_t CH59:1;

vuint32_t CH58:1;

vuint32_t CH57:1;

vuint32_t CH56:1;

vuint32_t CH55:1;

vuint32_t CH54:1;

vuint32_t CH53:1;

vuint32_t CH52:1;

vuint32_t CH51:1;

vuint32_t CH50:1;

vuint32_t CH49:1;

vuint32_t CH48:1;

vuint32_t CH47:1;

vuint32_t CH46:1;

vuint32_t CH45:1;

vuint32_t CH44:1;

vuint32_t CH43:1;

vuint32_t CH42:1;

vuint32_t CH41:1;

vuint32_t CH40:1;

vuint32_t CH39:1;

vuint32_t CH38:1;

vuint32_t CH37:1;

vuint32_t CH36:1;

vuint32_t CH35:1;

vuint32_t CH34:1;

vuint32_t CH33:1;

vuint32_t CH32:1;

} B;

} NCMR1;

union { /* ADC0 Normal Conversion Mask 2 (Base+0x00AC) */

vuint32_t R; /* (For external mux'd channels) */

struct {

vuint32_t CH95:1;

vuint32_t CH94:1;

vuint32_t CH93:1;

vuint32_t CH92:1;

vuint32_t CH91:1;

vuint32_t CH90:1;

vuint32_t CH89:1;

vuint32_t CH88:1;

vuint32_t CH87:1;

vuint32_t CH86:1;

vuint32_t CH85:1;

vuint32_t CH84:1;

vuint32_t CH83:1;

vuint32_t CH82:1;

vuint32_t CH81:1;

vuint32_t CH80:1;

vuint32_t CH79:1;

vuint32_t CH78:1;

vuint32_t CH77:1;

vuint32_t CH76:1;

vuint32_t CH75:1;

vuint32_t CH74:1;

vuint32_t CH73:1;

vuint32_t CH72:1;

vuint32_t CH71:1;

vuint32_t CH70:1;

vuint32_t CH69:1;

vuint32_t CH68:1;

vuint32_t CH67:1;

vuint32_t CH66:1;

vuint32_t CH65:1;

vuint32_t CH64:1;

} B;

} NCMR2;

vuint8_t ADC0_reserved6[4]; /* Reserved 4 bytes (Base+0x00B0-0x00B3) */

union { /* ADC0 Injected Conversion Mask0 (Base+0x00B4) */

vuint32_t R; /* (precision channels) */

struct {

vuint32_t :16;

vuint32_t CH15:1;

vuint32_t CH14:1;

vuint32_t CH13:1;

vuint32_t CH12:1;

vuint32_t CH11:1;

vuint32_t CH10:1;

vuint32_t CH9:1;

vuint32_t CH8:1;

vuint32_t CH7:1;

vuint32_t CH6:1;

vuint32_t CH5:1;

vuint32_t CH4:1;

vuint32_t CH3:1;

vuint32_t CH2:1;

vuint32_t CH1:1;

vuint32_t CH0:1;

} B;

} JCMR0;

union { /* ADC0 Injected Conversion Mask1 (Base+0x00B8) */

vuint32_t R; /* (standard channels) */

struct {

vuint32_t :4;

vuint32_t CH59:1;

vuint32_t CH58:1;

vuint32_t CH57:1;

vuint32_t CH56:1;

vuint32_t CH55:1;

vuint32_t CH54:1;

vuint32_t CH53:1;

vuint32_t CH52:1;

vuint32_t CH51:1;

vuint32_t CH50:1;

vuint32_t CH49:1;

vuint32_t CH48:1;

vuint32_t CH47:1;

vuint32_t CH46:1;

vuint32_t CH45:1;

vuint32_t CH44:1;

vuint32_t CH43:1;

vuint32_t CH42:1;

vuint32_t CH41:1;

vuint32_t CH40:1;

vuint32_t CH39:1;

vuint32_t CH38:1;

vuint32_t CH37:1;

vuint32_t CH36:1;

vuint32_t CH35:1;

vuint32_t CH34:1;

vuint32_t CH33:1;

vuint32_t CH32:1;

} B;

} JCMR1;

union { /* ADC0 Injected Conversion Mask2 (Base+0x00BC) */

vuint32_t R; /* (external mux'd channels) */

struct {

vuint32_t CH95:1;

vuint32_t CH94:1;

vuint32_t CH93:1;

vuint32_t CH92:1;

vuint32_t CH91:1;

vuint32_t CH90:1;

vuint32_t CH89:1;

vuint32_t CH88:1;

vuint32_t CH87:1;

vuint32_t CH86:1;

vuint32_t CH85:1;

vuint32_t CH84:1;

vuint32_t CH83:1;

vuint32_t CH82:1;

vuint32_t CH81:1;

vuint32_t CH80:1;

vuint32_t CH79:1;

vuint32_t CH78:1;

vuint32_t CH77:1;

vuint32_t CH76:1;

vuint32_t CH75:1;

vuint32_t CH74:1;

vuint32_t CH73:1;

vuint32_t CH72:1;

vuint32_t CH71:1;

vuint32_t CH70:1;

vuint32_t CH69:1;

vuint32_t CH68:1;

vuint32_t CH67:1;

vuint32_t CH66:1;

vuint32_t CH65:1;

vuint32_t CH64:1;

} B;

} JCMR2;

vuint8_t ADC0_reserved7[4]; /* Reserved 4 bytes (Base+0x00C0-0x00C3) */

ADC_CHANNEL_TYPE_tag -----> ????? How can I tag??

error : Illegal operands 'volatile union' [ 'unsigned char' ---->> What mean?

I don't know.

Help me please.

0 Kudos

48 Views
khaleadpark
Contributor II

Why do errors occur?

I don't know....

0 Kudos