Hi to all,
I wished to measure voltage on a or some analog input voltage of the Pic. But I can not configure the FVR module.
When VDD = 5V, the LED lights up well at 1.2 V. But when VDD is below the threshold is also different. Yet in the datasheet section 14.0, the voltage VDD must not change the threshold "The Fixed Voltage Reference, or FVR, is a stable,
voltage reference, independent of VDD "
What do I configure wrong?
Is anyone can help me please
thank you in advance
PS: Flowcode V5.5.2.1
Steve
ADC on battery 12F1840
Moderator: Benj
- 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: ADC on battery 12F1840
Hi Steve,
The chip your using uses ADC type 23. I would recommend that you make the mod inside the ADC CAL C file as otherwise your changes at the start of main will likely be overwritten.
The CAL file can be located inside the Flowcode folder and your looking for PIC_CAL_ADC.
You may need to copy the file out of program files first to allow you to edit it in a text editor. Scroll down to ADC type 23 and then add/change the code in the Enable_ADC function.
Let me know how your getting on.
The chip your using uses ADC type 23. I would recommend that you make the mod inside the ADC CAL C file as otherwise your changes at the start of main will likely be overwritten.
The CAL file can be located inside the Flowcode folder and your looking for PIC_CAL_ADC.
You may need to copy the file out of program files first to allow you to edit it in a text editor. Scroll down to ADC type 23 and then add/change the code in the Enable_ADC function.
Let me know how your getting on.
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
-
- Posts: 36
- Joined: Mon Mar 12, 2012 9:14 pm
- Has thanked: 5 times
- Been thanked: 7 times
- Contact:
Re: ADC on battery 12F1840
Hi Benji,
I did not dare change the file type, but I did it anyway.
I changed as a result :
It works very well, the transition threshold is the same as at VDD = 5V to 3V.
Thank you for your help.
Steve
I did not dare change the file type, but I did it anyway.
I changed as a result :
Code: Select all
#ifdef MX_ADC_TYPE_23
MX_UINT8 * ansel_reg; //ANSEL register pointer
void FC_CAL_Enable_ADC (MX_UINT8 Channel, MX_UINT8 Conv_Speed, MX_UINT8 Vref, MX_UINT8 T_Charge)
{
adcon1 = (Conv_Speed & 0x07) << 4; //assign conversion rate
fvrcon = 0xC2; //Activation du module FVR pour ADC avec référence à 2.048V (FVREN, ADFVR<1:0>)
adcon1 = adcon1 | 0x03; //VREF est connecté au module FVR (ADPREF<1:0>)
adcon0 = adcon0 | 0x78; //FVR Buffer 1 Output (CHS<4:0>)
switch (Channel)
Thank you for your help.
Steve