Hi, I am using flowcode v3.4.7.48
With regard to the ADC ,I would like to be able to switch the ref. point from VDD to alternate pin, reason being to measure low voltage ( 0.01) with greater accuracy
I have 16F877a & 12f676 but am willing to use any pic if you could help with the code.
If you can't help directly, could you point me to the help files for custom components
many thanks
Rob
Changing ADC ref. point
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Changing ADC ref. point
Hello Rob
Ok you need to browse to the "Flowcode V3/FCD" directory and open the FCD file for your target device in your favorite text editor eg. notepad.
Find the
Ok you need to browse to the "Flowcode V3/FCD" directory and open the FCD file for your target device in your favorite text editor eg. notepad.
Find the
Code: Select all
section of the file and then find the line that starts "ADCCapture="
In the target datasheet goto the analogue to digital A/D section and find the register responsible for assigning Vref+. This will normally be adcon1.
For most targets the adcon1 register is given a value depending on the channel that is being sampled %a. Simply swap the adcon1 values (or appropriate register) for the corresponding value in the datasheet that switches the appropriate ADC channels on and also assigns the +Vref.
[b]Example - 16F877A sampling channel AN0 with Vref+ enabled.[/b]
#if (%a == 0)\n #define MX_ADC_TRIS_MSK 0x01\n #define MX_ADC_TRIS_REG trisa\n [b]adcon1 = 0x04;[/b]\n#endif\n
[b]Becomes[/b]
#if (%a == 0)\n #define MX_ADC_TRIS_MSK 0x01\n #define MX_ADC_TRIS_REG trisa\n [b]adcon1 = 0x05;[/b]\n#endif\n
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel