PIC16F18857 No access to EEPROM, failure on all sides

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
renew
Posts: 28
Joined: 24 Nov 2016 13:56

PIC16F18857 No access to EEPROM, failure on all sides

#1 Post by renew » 02 Feb 2023 20:22

Hi, people. I am using PIC16F18857 this time and as usual I triedto use the built-in EEPROM library which is very easy

Code: Select all

int a;
a = 5;
EEPROM_Write(0x0000, a);
a = EEPROM_Read(0x0000);
But it does not work, the reading result is always 0.

I wrote my own lib

Code: Select all

char EEPROM_Read(char a){
   NVMREGS_bit = 1; // to eeprom
   NVMADRH = 0xF0;
   NVMADRL = a;
   NVMCON1.B0 = 1; // RD = 1
   while(NVMCON1.B0){asm NOP;}
   return NVMDATL;
}
But it does not work too, result is always 0, it should be 255 from freshly erased cells.

I have tried to use the built-in EEPROM Tool, to write first cell to some value, but output HEX causes error while import to Microchip IPE - "this file contanes data by outrange allowed address for PIC16F18857".

So I tried everithing what I could and dont know what to do next.

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: PIC16F18857 No access to EEPROM, failure on all sides

#2 Post by janni » 02 Feb 2023 21:00

That's due to error in definition file - follow instructions in this topic. The fix is for another processor but will work for yours as well.

renew
Posts: 28
Joined: 24 Nov 2016 13:56

Re: PIC16F18857 No access to EEPROM, failure on all sides

#3 Post by renew » 02 Feb 2023 22:40

Hi. Thank you.
That fix allows me to use EEPROM Editor tool properly.
Now I can set needed cells by values.

But I still cant read and write cells with built-in library and with my reading function.

Actually the correct address is 0xF000

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: PIC16F18857 No access to EEPROM, failure on all sides

#4 Post by janni » 03 Feb 2023 01:58

renew wrote:
02 Feb 2023 22:40
Actually the correct address is 0xF000
Yes, but compiler automatically adds 0xF000 to EEPROM address parameters in .mlk file so the addresses there do not need the offset.
That fix allows me to use EEPROM Editor tool properly.
Now I can set needed cells by values.
:)

Code: Select all

But I still cant read and write cells with built-in library and with my reading function.
Don't know why - your function looks fine (though there's no need to wait for the RD bit).

renew
Posts: 28
Joined: 24 Nov 2016 13:56

Re: PIC16F18857 No access to EEPROM, failure on all sides

#5 Post by renew » 03 Feb 2023 02:58

I have found that

Code: Select all

NVMDATL = 1;
NVMDATH = 2;
Write_Integer(160, 6, NVMDATL + NVMDATH, 5);
Both registers are always zero regardless of what is was written in them before.
:x :x :x :x

renew
Posts: 28
Joined: 24 Nov 2016 13:56

Re: PIC16F18857 No access to EEPROM, failure on all sides

#6 Post by renew » 03 Feb 2023 03:20

From datasheet:
When read access is initiated on an address outside
the parameters listed in Table 10-3, the NVMDATH:
NVMDATL register pair is cleared, reading back ‘0’s.

renew
Posts: 28
Joined: 24 Nov 2016 13:56

Re: PIC16F18857 No access to EEPROM, failure on all sides

#7 Post by renew » 03 Feb 2023 03:43

I am sorry !!!
NVM Module was disabled by PMD Control.
All works now
:oops:

Post Reply

Return to “mikroC PRO for PIC General”