Selecting a 2.048V reference voltage in PIC16F15324

Moderator: Benj

Lagoda
Posts: 153
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 66 times
Been thanked: 60 times
Contact:

Selecting a 2.048V reference voltage in PIC16F15324

Postby Lagoda » Thu Feb 07, 2019 9:04 am

Hi Ben,

I would like to use the ADC module of PIC16F15324 MCU .
The Vdd of the circuit is 3.3V.
I set the reference voltage source to the FVR on the AD Properties tab.
I inserted the following line in C code: FVRCON = 0x82; to select the 2.048V internal reference source. But is not working.
Based on the result of the AD conversion, the reference voltage is always 3.3V and I can't change it, but I really want it. :)

Can you help me?

Best regards,

Lagoda

User avatar
Benj
Matrix Staff
Posts: 14786
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4750 times
Been thanked: 4358 times
Contact:

Re: Selecting a 2.048V reference voltage in PIC16F15324

Postby Benj » Thu Feb 07, 2019 11:06 am

Hello,

I've found the bug and I'll push a fix to the v8 update system for you tomorrow.

If you want the fix today then you can apply it yourself by going here. "C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC"

Open the file "PIC_CAL_ADC.c" in a text editor and find line 6356, it should look like this.

Code: Select all

         ADCON0 = ADCON0 | Vref;            //Mod to allow FVR as VREF


Change the 0s to 1s and save the file.

Code: Select all

         ADCON1 = ADCON1 | Vref;            //Mod to allow FVR as VREF


Hope this helps.
These users thanked the author Benj for the post:
Lagoda (Thu Feb 07, 2019 12:15 pm)
Rating: 5%
 

Lagoda
Posts: 153
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 66 times
Been thanked: 60 times
Contact:

Re: Selecting a 2.048V reference voltage in PIC16F15324

Postby Lagoda » Thu Feb 07, 2019 12:34 pm

Hi Ben,


Thanks for the quick response.
I made the change and restarted the Flowcode.
Unfortunately, the situation is the same as before.

Maybe the value from the Vref variable does not come from the properties tab?

Do you have any ideas yet?

User avatar
Benj
Matrix Staff
Posts: 14786
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4750 times
Been thanked: 4358 times
Contact:

Re: Selecting a 2.048V reference voltage in PIC16F15324

Postby Benj » Thu Feb 07, 2019 12:55 pm

Hello,

I checked the value passed from the ADC properties and this looks correct. i.e. 3 for FVR. Not sure what else could be at fault here? You didn't do an update did you after restarting Flowcode as this will revert the CAL ADC file back to stock.

Lagoda
Posts: 153
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 66 times
Been thanked: 60 times
Contact:

Re: Selecting a 2.048V reference voltage in PIC16F15324

Postby Lagoda » Thu Feb 07, 2019 1:04 pm

Hi,


I didn't update, because it was up to date.
These users thanked the author Lagoda for the post:
Benj (Thu Feb 07, 2019 1:06 pm)
Rating: 5%
 

Lagoda
Posts: 153
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 66 times
Been thanked: 60 times
Contact:

Re: Selecting a 2.048V reference voltage in PIC16F15324

Postby Lagoda » Thu Feb 07, 2019 2:09 pm

I've tried the next change in PIC_CAL_ADC.c, but the situation hasn't changed.
CAL_ADC_mod.jpg
CAL_ADC_mod.jpg (18.27 KiB) Viewed 1189 times

Does this help you?

Lagoda
Posts: 153
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 66 times
Been thanked: 60 times
Contact:

Re: Selecting a 2.048V reference voltage in PIC16F15324

Postby Lagoda » Fri Feb 08, 2019 9:06 am

Hello Ben,

For now, this seems to be a paranormal phenomenon.
On another desktop PC, the unchanged project file produces a hex file without error and the MCU works correctly.
On this machine is same Flowcode version 8.1.1.11 , but it is not completely up to date.
I don't understand. :roll:

Best regards,

Lagoda