Code: Select all
Weighing Scale V3 ORG FROM POST.c(685:23): error: unknown identifier 'ADCS2'
Weighing Scale V3 ORG FROM POST.c(685:23): error: invalid operand 'ADCS2'
Weighing Scale V3 ORG FROM POST.c(685:18): error: failed to generate expression
Weighing Scale V3 ORG FROM POST.c(685:18): error: invalid operand '<<'
Weighing Scale V3 ORG FROM POST.c(685:12): error: failed to generate expression
Weighing Scale V3 ORG FROM POST.c(693:33): error: unknown identifier 'ADC_2'
Weighing Scale V3 ORG FROM POST.c(693:33): error: invalid operand 'ADC_2'
Weighing Scale V3 ORG FROM POST.c(693:39): error: failed to generate expression
Weighing Scale V3 ORG FROM POST.c(693:39): error: invalid operand '<<'
Weighing Scale V3 ORG FROM POST.c(693:30): error: failed to generate expression
Weighing Scale V3 ORG FROM POST.c(693:30): error: invalid operand '| '
Weighing Scale V3 ORG FROM POST.c(693:9): error: failed to generate expression
However using 16F887 this is from the ADC part of the C file:
Code: Select all
void FCD_ADC0_SampleADC()
{
/*******Supported Devices******************************************************************
// 16C72, 16C72A, 16CR72, 16F72, 16C73, 16C73A, 16C73B, 16F73, 16C74, 16C74A, 16C74B, 16F74,
// 16C76, 16F76, 16C77, 16F77, 16F818, 16F819, 16F870, 16F871, 16F872, 16F873, 16F873A,
// 16F874, 16F874A, 16F876, 16F876A, 16F877, 16F877A,
******************************************************************************************/
#define MX_ADC_CHANNEL ADC_2
#define MX_ADC_SAMP_TIME 1
#define MX_ADC_CONV_SP 40
#define MX_ADC_VREF_OPT 3
//set up ADC conversion
char old_tris, cnt;
//find appropriate bit
#if (MX_ADC_CHANNEL == 0)
#define MX_ADC_TRIS_MSK 0x01
#define MX_ADC_TRIS_REG trisa
#if (MX_ADC_VREF_OPT == 0)
adcon1 = 0x0E;
#else
adcon1 = 0x05;
#endif
#endif
#if (MX_ADC_CHANNEL == 1)
#define MX_ADC_TRIS_MSK 0x02
#define MX_ADC_TRIS_REG trisa
#if (MX_ADC_VREF_OPT == 0)
adcon1 = 0x04;
#else
adcon1 = 0x08;
#endif
#endif
#if (MX_ADC_CHANNEL == 2)
#define MX_ADC_TRIS_MSK 0x04
#define MX_ADC_TRIS_REG trisa
#if (MX_ADC_VREF_OPT == 0)
adcon1 = 0x02;
#else
adcon1 = 0x03;
#endif
#endif
#if (MX_ADC_CHANNEL == 3)
#define MX_ADC_TRIS_MSK 0x08
#define MX_ADC_TRIS_REG trisa
#if (MX_ADC_VREF_OPT == 0)
adcon1 = 0x04;
#else
#pragma error "Target device is currently using AN3 for VREF+"
#endif
#endif
#if (MX_ADC_CHANNEL == 4)
#define MX_ADC_TRIS_MSK 0x20
#define MX_ADC_TRIS_REG trisa
#if (MX_ADC_VREF_OPT == 0)
adcon1 = 0x02;
#else
adcon1 = 0x03;
#endif
#endif
#if (MX_ADC_CHANNEL == 5)
#define MX_ADC_TRIS_MSK 0x01
#define MX_ADC_TRIS_REG trise
#if (MX_ADC_VREF_OPT == 0)
adcon1 = 0x09;
#else
adcon1 = 0x01;
#endif
#endif
#if (MX_ADC_CHANNEL == 6)
#define MX_ADC_TRIS_MSK 0x02
#define MX_ADC_TRIS_REG trise
#if (MX_ADC_VREF_OPT == 0)
adcon1 = 0x00;
#else
adcon1 = 0x01;
#endif
#endif
#if (MX_ADC_CHANNEL == 7)
#define MX_ADC_TRIS_MSK 0x04
#define MX_ADC_TRIS_REG trise
#if (MX_ADC_VREF_OPT == 0)
adcon1 = 0x00;
#else
adcon1 = 0x01;
#endif
#endif
//sanity check
#ifndef MX_ADC_TRIS_REG
#pragma error "ADC Type 1 conversion code error - please contact technical support"
#endif
//assign conversion speed
#if (MX_ADC_CONV_SP > 3)
st_bit(adcon1, ADCS2);
#endif
//store old tris value, and set the i/o pin as an input
old_tris = MX_ADC_TRIS_REG;
MX_ADC_TRIS_REG = MX_ADC_TRIS_REG | MX_ADC_TRIS_MSK;
//turn ADC on
adcon0 = (0x01 | (MX_ADC_CONV_SP << 6)) | (MX_ADC_CHANNEL << 3);
//wait the acquisition time
cnt = 0;
while (cnt < MX_ADC_SAMP_TIME) cnt++;
//begin conversion and wait until it has finished
adcon0 = adcon0 | 0x04;
while (adcon0 & 0x04);
//restore old tris value, and reset adc registers
MX_ADC_TRIS_REG = old_tris;
adcon1 = 0x07;
adcon0 = 0x00;
#undef MX_ADC_CHANNEL
#undef MX_ADC_TRIS_REG
#undef MX_ADC_TRIS_MSK
#undef MX_ADC_SAMP_TIME
#undef MX_ADC_CONV_SP
#undef MX_ADC_VREF_OPT
}
MX_UINT8 FCD_ADC0_ReadAsByte()
{
MX_UINT8 retVal;
//Configure & Enable ADC Channel
FC_CAL_Enable_ADC ( ADC_2_MX_ADC_CHANNEL , ADC_2_MX_ADC_CONVSP , ADC_2_MX_ADC_VREFOP , ADC_2_MX_ADC_ACTIME );
retVal = FC_CAL_Sample_ADC( 0 ); //Perform Sample - Return as byte
FC_CAL_Disable_ADC ();
return (retVal);
}
MX_UINT16 FCD_ADC0_ReadAsInt()
{
MX_UINT16 retVal;
//Configure & Enable ADC Channel
FC_CAL_Enable_ADC ( ADC_2_MX_ADC_CHANNEL , ADC_2_MX_ADC_CONVSP , ADC_2_MX_ADC_VREFOP , ADC_2_MX_ADC_ACTIME );
retVal = FC_CAL_Sample_ADC( 1 ); //Perform Sample - Return as MX_UINT16
FC_CAL_Disable_ADC ();
return (retVal);
}
MX_FLOAT FCD_ADC0_ReadAsVoltage()
{
MX_UINT16 iSample;
MX_FLOAT fSample, fVoltage, fVperDiv;
//Configure & Enable ADC Channel
FC_CAL_Enable_ADC ( ADC_2_MX_ADC_CHANNEL , ADC_2_MX_ADC_CONVSP , ADC_2_MX_ADC_VREFOP , ADC_2_MX_ADC_ACTIME );
#ifdef MX_ADC_BITS_8
iSample = FC_CAL_Sample_ADC( 0 ); //Perform Sample - Return as byte
#else
iSample = FC_CAL_Sample_ADC( 1 ); //Perform Sample - Return as MX_UINT16
#endif
FC_CAL_Disable_ADC (); //Switch off ADC peripheral
fVoltage = float32_from_int32( ADC_2_MX_ADC_VREFVOL ); //Convert reference voltage count to floating point (0 - 500 x 10mV)
fVoltage = float32_mul(fVoltage, 0.01); //Convert reference voltage count to actual voltage (0 - 5)
#ifdef MX_ADC_BITS_8
fVperDiv = float32_mul(fVoltage, 0.00390625); //Convert actual voltage to voltage per division (VRef / 256)
#endif
#ifdef MX_ADC_BITS_10
fVperDiv = float32_mul(fVoltage, 0.000976); //Convert actual voltage to voltage per division (VRef / 1024)
#endif
#ifdef MX_ADC_BITS_12
fVperDiv = float32_mul(fVoltage, 0.00024414); //Convert actual voltage to voltage per division (VRef / 4096)
#endif
fSample = float32_from_int32(iSample); //Convert to floating point variable
fVoltage = float32_mul(fSample, fVperDiv); //Calculate floating point voltage
return (fVoltage);
}
void FCD_ADC0_ReadAsString(MX_CHAR* FCR_RETVAL, MX_UINT8 FCR_RETVAL_SIZE)
{
MX_FLOAT fVoltage;
fVoltage = FCD_ADC0_ReadAsVoltage();
FCI_FLOAT_TO_STRING(fVoltage, 2, FCR_RETVAL, FCR_RETVAL_SIZE); //Convert to String
}
void FCD_ADC0_ADC_RAW_Configure_Channel()
{
//Configure & Enable ADC Channel
FC_CAL_Enable_ADC ( ADC_2_MX_ADC_CHANNEL , ADC_2_MX_ADC_CONVSP , ADC_2_MX_ADC_VREFOP , ADC_2_MX_ADC_ACTIME );
}
MX_UINT8 FCD_ADC0_ADC_RAW_Sample_Channel_Byte()
{
return FC_CAL_Sample_ADC( 0 ); //Perform Sample - Return as byte
}
MX_UINT16 FCD_ADC0_ADC_RAW_Sample_Channel_Int()
{
return FC_CAL_Sample_ADC( 1 ); //Perform Sample - Return as MX_UINT16
}
MX_UINT8 FCD_ADC0_ADC_RAW_Average_Channel_Byte(MX_UINT8 NumSamples, MX_UINT8 DelayUs)
{
MX_UINT32 average = 0;
MX_UINT8 count;
for (count=0; count<NumSamples; count++)
{
average = average + FC_CAL_Sample_ADC( 0 ); //Perform Sample - Return as byte - add to average
if (DelayUs)
delay_us(DelayUs); //If delay is not 0 then pause between samples
}
average = average / count;
return (average & 0xFF); //Return average as byte
}
MX_UINT16 FCD_ADC0_ADC_RAW_Average_Channel_Int(MX_UINT8 NumSamples, MX_UINT8 DelayUs)
{
MX_UINT32 average = 0;
MX_UINT8 count;
for (count=0; count<NumSamples; count++)
{
average = average + FC_CAL_Sample_ADC( 1 ); //Perform Sample - Return as MX_UINT16 - add to average
if (DelayUs)
delay_us(DelayUs); //If delay is not 0 then pause between samples
}
average = average / count;
return (average & 0x1FFF); //Return average as MX_SINT16
}
void FCD_ADC0_ADC_RAW_Disable_Channel()
{
FC_CAL_Disable_ADC (); //Disable ADC Channel
Code: Select all
/*******Supported Devices******************************************************************
// 16C72, 16C72A, 16CR72, 16F72, 16C73, 16C73A, 16C73B, 16F73, 16C74, 16C74A, 16C74B, 16F74,
// 16C76, 16F76, 16C77, 16F77, 16F818, 16F819, 16F870, 16F871, 16F872, 16F873, 16F873A,
// 16F874, 16F874A, 16F876, 16F876A, 16F877, 16F877A,
******************************************************************************************/
#define MX_ADC_CHANNEL ADC_2
Since Type 1 devices is being pickup (16F887 is type7 ) and ADC_2 is in place of a number.
I have suggest to delete ADC and re-add component which fixes the issue.
See:
http://www.matrixmultimedia.com/mmforum ... =7&t=10360
Original file can be found here:
http://www.matrixmultimedia.com/mmforum ... 162#p32695
Martin