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
User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8874
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
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 128 times
An0 Test.fcfx
(6.69 KiB) Downloaded 99 times
Martin

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

User avatar
LeighM
Matrix Staff
Posts: 2043
Joined: Tue Jan 17, 2012 10:07 am
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

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8874
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
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

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

User avatar
LeighM
Matrix Staff
Posts: 2043
Joined: Tue Jan 17, 2012 10:07 am
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