Hi Uli,
AN2 is where i put the pull up resistor from vss. Is this a problem? I see this pin is also for vref+
I think this should work fine as long as the +VREF is not enabled. All you should have to do is change the ADC component connection to AN2.
Also I see that the ADC channel is set to FOSC/2 is that not a bit fast? Or does it not matter for capacitive touch?
This really needs to be based on your clock frequency. Using the RC conversion method was a bit too slow on my hardware and Fosc/2 was generating good results. Have a play around and see what setting provides you with the accuracy your after.
Is the problem I have due to a bug in Flowcode 5.5 or is there something wrong wit connecting the 1K pull up resistor to AN2
There is a specific bug for doing this in v5.5, as I say making the DSP stuff more optimized has broken my cap touch demo file.
To fix the bug have a look at the generated C code file and near the top it will tell you which ADC type your chip is using.
Go into the CAL and open the CAL_ADC file. You may have to copy the file out of the program files folder first to be able to edit it.
Find the ADC section for your device - has the same type number and then look for this line of code at the end of the Enable ADC function.
Should look something like this.
Code: Select all
adcon0 = adcon0 | 0x04; //begin next conversion
Cut the line of code out so that the last line is the delay_us function.
Then paste the line of code into the Sample_ADC function just above the while line of code.
E.g. this code
Code: Select all
*tris_reg = old_tris | tris_mask;
adcon0 = (0x01 | (Conv_Speed << 6)) | (Channel << 3); //turn ADC on
delay_us(T_Charge); //wait the acquisition time
adcon0 = adcon0 | 0x04; //begin next conversion
}
MX_UINT16 FC_CAL_Sample_ADC (MX_UINT8 Sample_Mode)
{
MX_UINT16 iRetVal;
while (adcon0 & 0x04);
if (Sample_Mode)
Changes to this code
Code: Select all
*tris_reg = old_tris | tris_mask;
adcon0 = (0x01 | (Conv_Speed << 6)) | (Channel << 3); //turn ADC on
delay_us(T_Charge); //wait the acquisition time
}
MX_UINT16 FC_CAL_Sample_ADC (MX_UINT8 Sample_Mode)
{
MX_UINT16 iRetVal;
adcon0 = adcon0 | 0x04; //begin next conversion
while (adcon0 & 0x04);
if (Sample_Mode)
Or you can tell me which device your using and I will make the mod for you.