View previous topic :: View next topic |
Author |
Message |
veerabahu
Joined: 20 Aug 2013 Posts: 16
|
EEPROM Write problem in 18f66k22 |
Posted: Sun Nov 16, 2014 8:23 am |
|
|
Hi experts,
I am developing a project in 18f66k22 with GLCD. The problem is EEPROM, i can't able to write a data into internal & external EEPROM. I googled & i came to know that need to disable the write protection option for EEPROM. But i didn't get the procedure to disable the write protection. I think this will be the problem. Can anyone please help me to solve this issue.
Thanks in advance
Veera |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19499
|
|
Posted: Sun Nov 16, 2014 9:35 am |
|
|
#fuses NOCPD
This is a 'read the data sheet' problem at this point.
This though will have no effect on an external EEPROM. For this it is down to how the external EEPROM is connected, what chip it is, and what protection options this chip has?. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Nov 16, 2014 9:58 am |
|
|
Quote: | i can't able to write a data into internal & external EEPROM. |
The fact that you can't make either one work, makes it very unlikely
that it's caused by write protection. You're probably just not doing
it correctly, or your PIC is not running. |
|
|
jgschmidt
Joined: 03 Dec 2008 Posts: 184 Location: Gresham, OR USA
|
|
Posted: Sun Nov 16, 2014 10:23 am |
|
|
I'm using the same chip with version 4.135 and the following setup:
Code: | #include <18F26K22.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES NOPUT //No Power Up Timer
#FUSES MCLR //Allow reset button
#FUSES NOBROWNOUT //No brownout reset
#use delay(internal=64M,clock_out)
//------ EEPROM INT16 MACROS CCS Forum Post # 40941 by Michael Bradley
// a few internal eeprom macro wrappers
#define mReadByte(addr) read_eeprom(addr)
#define mWriteByte(addr,data) write_eeprom(addr,data)
// little endian - remember to increment addr by 2 !!!!
#define mReadWord(addr) make16( read_eeprom(addr + 1), read_eeprom(addr) )
#define mWriteWord(addr, data) { write_eeprom(addr, make8(data,0) ); write_eeprom(addr + 1, make8(data,1)); }
|
and it works great for reading and writing internal EEPROM. _________________ Jürgen
www.jgscraft.com |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19499
|
|
Posted: Sun Nov 16, 2014 10:43 am |
|
|
You need to be fractionally 'beware'....
There have been a number of problems with particular compiler versions, where CCS changed the 'defaults' on some fuses. With your compiler, it is defaulting to 'no protection', but there is no guarantee that this will be the case in the future. Always better to actually specify everything.
However as you see, I agree with PCM programmer, that something else is almost certainly the problem, since the internal fuse has no effect whatever on an external EEPROM.... |
|
|
jgschmidt
Joined: 03 Dec 2008 Posts: 184 Location: Gresham, OR USA
|
|
Posted: Sun Nov 16, 2014 1:07 pm |
|
|
Thanks for the warning about the NOCPD fuse. I haven't needed it so far but I'll add it to my default setup. _________________ Jürgen
www.jgscraft.com |
|
|
veerabahu
Joined: 20 Aug 2013 Posts: 16
|
I tried with NOCPD,but it didn't work for me |
Posted: Mon Nov 17, 2014 8:20 am |
|
|
Hi Ttelmah,
As per your advice i tried with #fuses NOCPD, but it didn't work for me. I don't know what mistake i am doing.
This is my code, I am using CCS 4.11 ver and 16Mhz is my crystal value. Please guide me to get out of this problem.
Code: | #include <18F66K22.h>
#FUSES HS //No Watch Dog Timer
#FUSES NOWDT //No Watch Dog Timer
#FUSES NOPUT //No Power Up Timer
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOCPD
#use delay(clock=16000000)
#include <hdn64s.c>
#include <graphics.c>
void main()
{
char customtext[20]={0};
unsigned int8 ui8Value=0;
glcd_init(ON);
delay_ms(1000);
glcd_fillScreen(0);
glcd_rect(0, 0, 125, 63, NO, ON);
strcpy(customtext,"EEPROM TEST ");
glcd_text57(25, 10, customtext,1,ON);
delay_ms(1000);
write_eeprom(5,22);
delay_ms(100);
ui8Value=read_eeprom(5);
sprintf(customtext,"%u",ui8Value);
glcd_text57(30, 25, customtext,1,ON);
delay_ms(1000);
} |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19499
|
|
Posted: Mon Nov 17, 2014 8:31 am |
|
|
4.11, is not a CCS version. They are in the format 4.xxx always three digits. Look at the top of the .lst file for the version, and tell us it.
If it is 4.011, then 'give up hope'. That was 'at best' a beta, and long before V4 started to work. It was about 4.065, before it became useable. Something like a five year old version... |
|
|
veerabahu
Joined: 20 Aug 2013 Posts: 16
|
|
Posted: Mon Nov 17, 2014 8:43 am |
|
|
ya.. Actually its CCS PCH C Compiler, Version 4.110 |
|
|
jgschmidt
Joined: 03 Dec 2008 Posts: 184 Location: Gresham, OR USA
|
|
Posted: Mon Nov 17, 2014 2:48 pm |
|
|
= = = deleted = = =
Oops, if anyone saw the original reply, I was working with 26K22, not 66K22. My 26K22 works fine with the code shown (I replaced the GLCD with printf statements) but I don't have a 66K22 to work with. Sorry for any confusion I may have caused. _________________ Jürgen
www.jgscraft.com |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19499
|
|
Posted: Tue Nov 18, 2014 1:42 am |
|
|
OK. With 4.110, I suspect the problem is with the compiler version. The 66K22, was only added a couple of versions before, and CCS often get the device database 'wrong' when a chip is newly added. The chip is not present in 4.107. There were definately problems with quite a few chips when they were first added.
You probably need to write your own EEPROM code, or update the compiler. |
|
|
veerabahu
Joined: 20 Aug 2013 Posts: 16
|
|
Posted: Wed Nov 19, 2014 12:57 am |
|
|
Thanks for your reply Ttelmah, This is purely version problem. Its worked in ver5.015.
Thanks for eveyrone. |
|
|
|