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

Post Reply
medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

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

Post by medelec35 »

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
(97.78 KiB) Downloaded 235 times
An0 Test.fcfx
(6.69 KiB) Downloaded 211 times
Martin

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

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

Post by LeighM »

Hi Martin,

I think this is the same issue as ...

http://www.matrixtsl.com/mmforums/viewt ... =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

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

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

Post by medelec35 »

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

Thanks

Martin
Martin

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

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

Post by LeighM »

No worries... at least your "subject" will get more attention and search results :D

Post Reply