Bug: ADC 16F1933,16F1934,16F1936,16F1937 & 16F1939 [SOLVED]

A forums to allow bugs and problems with Flowcode v6 to be reported and resolved.

Moderator: Benj

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3451 times
Contact:

Bug: ADC 16F1933,16F1934,16F1936,16F1937 & 16F1939 [SOLVED]

Postby medelec35 » Sat Feb 14, 2015 1:40 pm

Using V6.1.1.0:
ADC does not obtain correct value from any of the channels (Tested with 16F1937)
For example using GetByte on AN1.
If ADC is supposed to be 200 when working correctly, then with the bug the readings I was getting:

Code: Select all

0
64
0
128
0
64
0
128

etc

After investigation I found it's not a bug with Flowcode, but a bug within boostC header files PIC16F19xx.h
There is a define for both adres and adresl for the same address:

Code: Select all

#define ADRES                 0x009B
#define ADRESL                0x009B

Therefore the ADC conversion is being done as though there is an adres register within 16F1937 and there is not.
Attached is an unofficial fix if anyone is stuck with ADC conversion because of this bug.

If you make a backup copy and replace:
PIC_CAL_ADC.c that's in:
C:\Program Files (x86)\Flowcode 6\CAL\PIC (If 64 bit windows)
or
C:\Program Files\Flowcode 6\CAL\PIC(If 32 bit windows.)
With the attached file, then ADC should read correct values allowing for BoostC bug.

I thought I would modify Flowcode file rather than Boostc header files since if there is a V6 update then we could be back to square1
Although that may not be the case as I don't know the bug correction process if there is a bug with BoostC

Martin

Edit: Official fix within link Leigh posted below
Attachments
PIC_CAL_ADC.c
(102.32 KiB) Downloaded 108 times
An0 Test.fcfx
(6.69 KiB) Downloaded 74 times
These users thanked the author medelec35 for the post (total 2):
kersing (Sat Feb 14, 2015 5:09 pm) • LeighM (Mon Feb 16, 2015 11:07 am)
Rating: 10.53%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
LeighM
Matrix Staff
Posts: 1919
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 461 times
Been thanked: 649 times
Contact:

Re: Bug: ADC 16F1933, 16F1934, 16F1936, 16F1937 & 16F1939

Postby LeighM » Mon Feb 16, 2015 11:02 am

Hi Martin,

I think this is the same issue as ...

viewtopic.php?f=7&t=16142

My edited version as posted there is currently in our repo, could you try that one, and let us know if you think it needs changing?
Looks like your edits are similar to mine.
The only difference is the "iRetVal = iRetVal | (adres >> 6);" which I don't think is needed for the 8bit ADRES devices.

Thanks
Leigh
These users thanked the author LeighM for the post:
medelec35 (Wed Oct 14, 2015 6:34 pm)
Rating: 5.26%
 

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3451 times
Contact:

Re: Bug: ADC 16F1933, 16F1934, 16F1936, 16F1937 & 16F1939

Postby medelec35 » Mon Feb 16, 2015 11:16 am

ah,
Looks like you are correct.
I did not see that post :(
Sorry for replication.

Thanks

Martin
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
LeighM
Matrix Staff
Posts: 1919
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 461 times
Been thanked: 649 times
Contact:

Re: Bug: ADC 16F1933,16F1934,16F1936,16F1937 & 16F1939 [SOLV

Postby LeighM » Mon Feb 16, 2015 11:24 am

No worries... at least your "subject" will get more attention and search results :D
These users thanked the author LeighM for the post:
medelec35 (Wed Oct 14, 2015 6:34 pm)
Rating: 5.26%