16F886 EEPROM Problems

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
Ron
Posts: 225
Joined: Wed Apr 11, 2007 6:15 pm
Has thanked: 2 times

16F886 EEPROM Problems

Post by Ron »

Hello,

I have been trying to get a 16F886 EEPROM write to work but have had zero success. To make things more interesting, I have compiled this program for an 18F2620 and it works perfectly.

Has anyone actually tested the EEPROM component macro on a 16F886 and had it work?

I am running at 20MHz.

Configuration bits set as follows:

Oscillator = HS
Watchdog Timer = off
Power Up Timer = on
Master Clear Enable = /MCLR is external
Code protect = off
Data EE read protect = off
Brown Out Detect = BOD Enabled, SBOREN Disabled
Internal External Switch Over Mode = Disabled
Monitor Clock fail-safe = Disabled
Low Voltage Program = Disabled
Self Write Enable = No Protection
Brown Out Reset Sel Bit = Brown out at 4.0V

These settings have been tested with programs that have used both Digitall and Analog I/O on the 16F without any problems.

RA0 is analog 10K pot
RA1 is analog 50K pot
RA2 is analog 50K pot

RB0 - 7 are LEDs

RC0 - 3 are SPDT slide switches, center pin of switch tied to RC0, RC1, RC2,RC3. One end pin of switch is tied high via resistor, other end pin of switch is tied low via resistor(I did not want to accidentally pop PIC if I set pin as output).

Any idea what I am doing wrong?

I have tried 3 different 16F886 PICs.

Thanks

Ron

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Post by Steve »

Hello Ron,

I've just created a simple test program for a 16F883 that works well (I don't have an '886, but this chip is in the same family).

Are you running the latest version of Flowcode (v3.2.2)? The EEPROM component should be version 1.5.

Here is my test program:

Code: Select all

Call Component Macro:
EEPROM(0)::Write(0, 4)

Call Component Macro:
EEPROM(0)::Write(1, 6)

Call Component Macro:
EEPROM(0)::Write(2, 9)




Call Component Macro:
LCDDisplay(0)::Start

Call Component Macro:
x=EEPROM(0)::Read(1)

Call Component Macro:
LCDDisplay(0)::PrintNumber(x)

Call Component Macro:
LCDDisplay(0)::PrintString(";")




Call Component Macro:
x=EEPROM(0)::Read(0)

Call Component Macro:
LCDDisplay(0)::PrintNumber(x)

Call Component Macro:
LCDDisplay(0)::PrintString(";")




Call Component Macro:
x=EEPROM(0)::Read(2)

Call Component Macro:
LCDDisplay(0)::PrintNumber(x)
The LCD display should read "6;4;9".

Ron
Posts: 225
Joined: Wed Apr 11, 2007 6:15 pm
Has thanked: 2 times

Please add this feature to Flowcode - Issue was my fault

Post by Ron »

Hi,

It works fine, it was my fault.

I have been doing extensive testing of a bootloader program I have hired someone to write for me.

Everything I have tested works with the 18F version of the bootloader, everything EXCEPT writing, reading EEPROM works on the 16F. If I burn my program straight to the PIC all EEPROM features work.

New Feature in flowcode.......

I have a few different linker switches for the different bootloaders I am using. It would be nice to have the compiler/linker setting saved in the flowcode source file somehow.

This way when I open up the program all the proper switches are set (after I set them up the first time of course).

If this is not possible, then add 2 or 3 additional button that specific compiler/linker configs could be stored as. Similar to your default button. Please allow us to give each button a name, in my case 18FBL and 16FBL.

It is a real pain to bounce between 3 different configs, it is very easy to get mixed up.

Thanks for your help Steve, Sean, and Ben.

Ron

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Post by Steve »

Hello Ron,

Glad it works.

The suggestion for embedding compiler settings into each program may be a good one - I'll look into it.

We have a similar problem here (usually to change the programmer settings), and I'll tell you how we workaround it...

The compiler settings are stored in the Windows registry, and we use a .reg registry script file for each particular setting. To change the settings on-the-fly, we simply double-click the ".reg" file to change the registry settings.

For example, here is a registry file that modifies the compiler and linker/assembler settings:

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\matrixmm\FlowCodeV3\Compiler]
"CompilerSwitches"="-v -t PIC%p \"%f.c\""
"AssemblerSwitches"="-ld \"c:\\Program Files\\Matrix Multimedia\\Flowcode V3\\BoostC\\lib\" libc.pic18.lib flowcode.pic18.lib \"%f.obj\" -t PIC%p -d \"%d\" -p \"%f\""
(note that the "AssemblerSwitches" entry may be word-wrapped).

You may want one that relocates the code so that it begins at location 0x800 (because of a bootloader). Then you would use this:

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\matrixmm\FlowCodeV3\Compiler]
"CompilerSwitches"="-v -t PIC%p \"%f.c\""
"AssemblerSwitches"="-rb 0x800 -ld \"c:\\Program Files\\Matrix Multimedia\\Flowcode V3\\BoostC\\lib\" libc.pic18.lib flowcode.pic18.lib \"%f.obj\" -t PIC%p -d \"%d\" -p \"%f\""
But of course, be careful when modifying the registry - make sure you know what you are doing!

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Post by Steve »

Ron,

There is another way to provide the functionality you require - via the FCD files. If you create a copy the 16F886.fcd file in the "fcd" folder and rename it something like "16F886 (-rb800).fcd". Then edit this new file by adding the following lines to the end of the [Device] section:

Code: Select all

ChipName=16F886
ExtraLinkerParams=-rb 0x800
If you target this device instead of the "vanilla" '886 device, you will automatically add the appropriate linker commands each time.

You can also extend this by adding some hard-coded configuration options to the FCD file. To do this, you will need to add another line to the [Device] section:

Code: Select all

ConfigOverride=1
And then provide a new [Config] section with the appropriate values, eg:

Code: Select all

[Config]
0=0x2302
1=0x3FFF
2=0xFFFF
3=0xFFFF
4=0xFFFF
5=0xFFFF
6=0xFFFF
7=0xFFFF
8=0xFFFF
9=0xFFFF
10=0xFFFF
11=0xFFFF
12=0xFFFF
13=0xFFFF
Another thing you can do is to provide a hard-coded clock frequency. In the device section, add something like:

Code: Select all

ClockOverrideValue=10000000
There should be some FCD files that have mods similar to these already in your FCD folder ("16F88 (rc).fcd" and "ECIO-28.fcd" are 2 examples).

I hope this info helps.

Ron
Posts: 225
Joined: Wed Apr 11, 2007 6:15 pm
Has thanked: 2 times

Custom FCD file Config Bit Question

Post by Ron »

Steve,

The config bits you listed show 13 total. For the 16F886 MPlab only lists 2 addresses.

1) Is each address listed in MPLAB the same as a single line in MPLAB?

0=0x33E2 the same as 2007 in MPLAB for 16F886

2) Do all I need to do is set the configuration bit in MPLAB, and then enter the hex value displayed for that address in FCD? As you change the config bits the hex value for that address changes in MPLAB.

3) If I only have 2 addresses to change for config bits must I leave all the remaining lines in tact.


[Config]
0=0x33E2 (address 2007)
1=0x3EFF (address 2008)
2=0xFFFF
3=0xFFFF
4=0xFFFF
5=0xFFFF
6=0xFFFF
7=0xFFFF
8=0xFFFF
9=0xFFFF
10=0xFFFF
11=0xFFFF
12=0xFFFF
13=0xFFFF


Is there any PIC that uses more than 13 settings?

If yes, do we simply add more lines after 13?

Thanks

Ron

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Post by Steve »

The example you have written seems fine to me. I think you must include all 14 lines (0 to 13) and there are no PICmicro 16/18 chips I know of with more configuration words.

Ron
Posts: 225
Joined: Wed Apr 11, 2007 6:15 pm
Has thanked: 2 times

My Custom FCD file

Post by Ron »

Steve,

Here is what I added to the original 16F886.

I want 20MHz with linker option -rb 0x003 added.

; Ron Yemmans Start of Custom Code for 20MHz 16F886
; bootloader added the lines below to embed linker
; requirements, Clock Frequency and Configuration
; bits. End of code comment added by Ron Yemmans is
; commented to know what to remove to restore this
; file to original state.

ChipName=16F886
ExtraLinkerParams=-rb 0x003
ClockOverrideValue=20000000
ConfigOverride=1

; MPLAB configuration reads as follows
; 2007 23E2 Oscillator HS
; Watchdog Timer off
; Power Up Timer On
; Master Clear Enable /MCLR is external
; Code Protect off
; Data EE Rear Protect off
; Brown Out Detect BOD Enabled, SBOREN Disabled
; Internal External Switch Over Mode Disabled
; Monitor Clock Fail-safe Disabled
; Low Voltage Program Disabled
;
;2008 3EFF Self Write Enable No Protection
; Brown Out reset Sel Bit Brown Out at 2.1V


[Config]
0=0x23E2
1=0x3EFF
2=0xFFFF
3=0xFFFF
4=0xFFFF
5=0xFFFF
6=0xFFFF
7=0xFFFF
8=0xFFFF
9=0xFFFF
10=0xFFFF
11=0xFFFF
12=0xFFFF
13=0xFFFF


; End of edit by Ron Yemmans


The clock frequency in Flowocde shows up, grayed out at 20000000.

Chip - Config menu is grayed out

I do not see the -rb 0x003 in the linker parameter command line. Should -rb 0x003 be shown on the linker parameter line in compile window?

Thanks

Ron

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Post by Steve »

The option will not be added to the "Linker Parameters" line of the "Compiler Options" window. However, it will be added when the linker is actually run as part of the compilation process.

I've just tried this here and this is part of my output:

Code: Select all

   .
   .
   .

Launching the linker/assembler...

d:\Program Files\Matrix Multimedia\Flowcode V3\BoostC\boostlink.pic.exe -rb 0x123 -ld "d:\Program Files\Matrix Multimedia\Flowcode V3\BoostC\lib" libc.pic16.lib flowcode.pic16.lib  "unary minus.obj" -t PIC16F88 -d "C:\Documents and Settings\steve\My Documents\FlowCode Programs" -p "unary minus"

BoostLink Optimizing Linker Version 6.70
   .
   .
   .
I've also checked the HEX file to make sure the code location has changed.

Ron
Posts: 225
Joined: Wed Apr 11, 2007 6:15 pm
Has thanked: 2 times

Hard Code Bits Not Working - What Am I doning wrong?

Post by Ron »

Steve,

I have tried and have not been able to get -rb 0x003 to be added to the linker code when compiling.

Your example shows -rb 0x123, mine does not show -rb 0x003

Here are the modifications I currently have for 16F887.

[Device]
Pins=40
Ports=5
ADCPins=14
ADCBits=10
MaxClock=20000000
PrescalerBits=3
ClockDivider=4
TimerOverflow=256
ConfigAddress=0x2007
ConfigCount=2
PWMCount=2
EepromSize=256
HasAltPWM=0
Pwm2IsD4=0
FlowcodeProduct=PIC
ChipName=16F887
ExtraLinkerParams=-rb 0x003
ClockOverrideValue=20000000


Launching the linker/assembler...

C:\Program Files\Matrix Multimedia\Flowcode V3\BoostC\boostlink.pic.exe -ld "C:\Program Files\Matrix Multimedia\Flowcode V3\BoostC\lib" libc.pic16.lib flowcode.pic16.lib "Blink RA0.obj" -t PIC16F887 -d "C:\Documents and Settings\Ron\Desktop\Flowcode\bootloader test projects\16F Tests\16F887\FCD Tests" -p "Blink RA0"

BoostLink Optimizing Linker Version 6.70



Any ideas on what I am doing wrong?

Thanks

Ron

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Post by Steve »

Are you definitely targetting the modified 16F887 file, and not the original one?

Also, what version of Flowcode are you using?

Ron
Posts: 225
Joined: Wed Apr 11, 2007 6:15 pm
Has thanked: 2 times

Configuration Bits

Post by Ron »

Steve,

I copied the original FCD file. I then renamed it to 16F887 HS 20MHz and made changes I posted. I did a cut&paste from the FCD to the forum post. I have selected 16F887 HS 20MHz, not 16F887 for the target.

Clock option 20000000 is grayed out.

v3.2.2.40

Thanks

Ron

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Post by Steve »

Hi Ron,

I've looked into this and it seems that the "ExtraLinkerParams" option is only added to the Linker parameters when the configuration information is overridden. This is a small bug within Flowcode that has been fixed and will be available in the next update.

So you will need to add the "ConfigOverride=1" option to [Device] and add a [Config] section.

Ron
Posts: 225
Joined: Wed Apr 11, 2007 6:15 pm
Has thanked: 2 times

Configuration Bits

Post by Ron »

Hi,

The PC application that downloads the user program to the PIC looks to see what the last address of the program is and if it goes beyond the address where the bulk of the bootloader code resides then it says, program to large and does not allow the download.

I eagerly await when the parameters for the linker can be done by themselves.

Is this "feature" going to be released for V3 or V4?

Thanks

Ron

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Post by Steve »

You can add the extra linker parameters yourself via the "Compiler Options" window. That will be the best option if you do not want to add hardcoded configuration data to the FCD file.

Ron
Posts: 225
Joined: Wed Apr 11, 2007 6:15 pm
Has thanked: 2 times

compiler options

Post by Ron »

He,

Ben told me to install PPP and that when I select CHIP - Configure that I would be given the ability to add things.

I installed PPP and was never able to get anything other than an empty window.

Any ideas on how to get the proer window to display?

Thanks

Ron

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Post by Steve »

PPP needs to be selected as the programmer in the Compiler Options window, and the "Use programmer to set configuration options" option needs to be ticked.

Ron
Posts: 225
Joined: Wed Apr 11, 2007 6:15 pm
Has thanked: 2 times

Post by Ron »

Hi,

If I am not using the PPP, rather the MPLAB ICD2 Programmer will this cause any issues?

Thanks

Ron

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Post by Steve »

In this case, you are probably best entering the required config options within this "blank" window - unless you use some hardcoded values in your FCD file.

Ron
Posts: 225
Joined: Wed Apr 11, 2007 6:15 pm
Has thanked: 2 times

Post by Ron »

Hi,

What would I enter for the -rb 0x003 linker information?

Thanks

Ron

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Post by Steve »

Add the "-rb 0x003" to the linker parameters in the "compiler options" window.

Post Reply