Page 1 of 1

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

Posted: Sat Feb 14, 2015 1:40 pm
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

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

Posted: Mon Feb 16, 2015 11:02 am
by LeighM
Hi Martin,

I think this is the same issue as ...

http://www.flowcode.co.uk/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

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

Posted: Mon Feb 16, 2015 11:16 am
by medelec35
ah,
Looks like you are correct.
I did not see that post :(
Sorry for replication.

Thanks

Martin

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

Posted: Mon Feb 16, 2015 11:24 am
by LeighM
No worries... at least your "subject" will get more attention and search results :D