In trying to isolate the issue, I reduced the code to the following, ultra-simple, segment:-
This code does not compile – neither on Flowcode 7 Beta, nor on the very latest release (downloaded and installed yesterday evening)
This is the relevant section of the error message:-
Code: Select all
C:\Program Files (x86)\Flowcode 7\CAL\PIC\PIC_CAL_ADC.c: FC_CAL_ADC_Enable()
1933: ADCON0bits.VCFG0 = 1;
^ (255) not a member of the struct/union ""
^ (182) illegal conversion between types
Further investigation of the actual C file referenced in the error message showed that there was a pretty close similarity between the code segment for “ADC Type 2 Supported Devices (which included the 16F88) and “ADC Type 14 Supported Devices” (the 18F2331)
Extracts of these two C-code segments are shown below:-
For the 16F88
Code: Select all
// ADC Type 2 Supported Devices ************************************************************
// 16F88
// *****************************************************************************************/
#ifdef MX_ADC_TYPE_2
void FC_CAL_ADC_Enable (MX_UINT8 Channel, MX_UINT8 Conv_Speed, MX_UINT8 Vref, MX_UINT8 T_Charge)
{
if (Vref == 1) //assign VREF functionality
st_bit(ADCON1, VCFG1);
switch (Channel)
{
#ifdef MX_ADC_CHANNEL_0
case (0):
tris_mask = 0x01;
tris_reg = &TRISA;
ANSEL = 0x01;
break;
#endif
#ifdef MX_ADC_CHANNEL_1
case (1):
tris_mask = 0x02;
tris_reg = &TRISA;
ANSEL = 0x02;
break;
#endif
#ifdef MX_ADC_CHANNEL_2
case (2):
tris_mask = 0x04;
tris_reg = &TRISA;
ANSEL = 0x04;
break;
#endif
#ifdef MX_ADC_CHANNEL_3
case (3):
tris_mask = 0x08;
tris_reg = &TRISA;
ANSEL = 0x08;
break;
#endif
#ifdef MX_ADC_CHANNEL_4
case (4):
tris_mask = 0x10;
tris_reg = &TRISA;
ANSEL = 0x10;
break;
#endif
#ifdef MX_ADC_CHANNEL_5
case (5):
tris_mask = 0x20;
tris_reg = ⧍
ANSEL = 0x20;
break;
#endif
#ifdef MX_ADC_CHANNEL_6
case (6):
tris_mask = 0x40;
tris_reg = ⧍
ANSEL = 0x40;
break;
#endif
}
Code: Select all
// ADC Type 14 Supported Devices ***********************************************************
// 18F2331, 18F2431, 18F4331, 18F4431
// *****************************************************************************************/
#ifdef MX_ADC_TYPE_14
void FC_CAL_ADC_Enable (MX_UINT8 Channel, MX_UINT8 Conv_Speed, MX_UINT8 Vref, MX_UINT8 T_Charge)
{
ADCON1 = 0x00; //set up ADC conversion
ADCON2 = Conv_Speed & 0x07;
ADCON3 = 0x00;
ADCHS = 0x00;
switch (Channel)
{
#ifdef MX_ADC_CHANNEL_0
case (0):
tris_mask = 0x01;
tris_reg = &TRISA;
ADCON0 = 0x00;
ANSEL0 = 0x01;
break;
#endif
#ifdef MX_ADC_CHANNEL_1
case (1):
tris_mask = 0x02;
tris_reg = &TRISA;
ADCON0 = 0x04;
ANSEL0 = 0x02;
break;
#endif
#ifdef MX_ADC_CHANNEL_2
case (2):
tris_mask = 0x04;
tris_reg = &TRISA;
ADCON0 = 0x08;
ANSEL0 = 0x04;
break;
#endif
#ifdef MX_ADC_CHANNEL_3
case (3):
tris_mask = 0x08;
tris_reg = &TRISA;
ADCON0 = 0x0C;
ANSEL0 = 0x08;
#endif
#ifdef MX_ADC_CHANNEL_4
case (4):
tris_mask = 0x10;
tris_reg = &TRISA;
ADCON0 = 0x00;
ADCHS = 0x01;
ANSEL0 = 0x10;
break;
#endif
#ifdef MX_ADC_CHANNEL_5
case (5):
tris_mask = 0x20;
tris_reg = &TRISA;
ADCON0 = 0x04;
ADCHS = 0x10;
ANSEL0 = 0x20;
break;
#endif
#ifdef MX_ADC_CHANNEL_6
case (6):
tris_mask = 0x01;
tris_reg = &TRISE;
ADCON0 = 0x08;
ADCHS = 0x04;
ANSEL0 = 0x40;
break;
#endif
#ifdef MX_ADC_CHANNEL_7
case (7):
tris_mask = 0x02;
tris_reg = &TRISE;
ADCON0 = 0x0C;
ADCHS = 0x40;
ANSEL0 = 0x80;
break;
#endif
#ifdef MX_ADC_CHANNEL_8
case (8):
tris_mask = 0x04;
tris_reg = ⧍
ADCON0 = 0x00;
ADCHS = 0x02;
ANSEL1 = 0x01;
break;
#endif
}
old_tris = *tris_reg; //store old tris value, and set the i/o pin as an input
*tris_reg = old_tris | tris_mask;
ADCON0 = ADCON0 | 0x01; //turn ADC on
if (Vref != 0) //assign VREF functionality
st_bit(ADCON0, VCFG0);
delay_us(T_Charge); //wait the acquisition time
ADCON0 = ADCON0 | 0x02; //begin next conversion
}
Code: Select all
if (Vref == 1) //assign VREF functionality
st_bit(ADCON1, VCFG1);
However, the main code also now compiles to HEX – so I can now see how much code memory I have left to work with.
I have attached the modified C file which I am now using to allow my project to move forward.
Could someone with better knowledge of low-level programming and configuration of PIC chips please look into this matter and,
a.) Determine if I have identified a valid ‘bug’
b.) Verify that my proposed solution is actually ‘correct’
Any, and all, help would be greatly appreciated.
Cheers,
Bill