Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 10, 2016, 02:06:28 02:06


Login with username, password and session length


Pages: [1]
Print
Author Topic: c18 and xc8 flash and eeprom variables?  (Read 5882 times)
0 Members and 1 Guest are viewing this topic.
pumper
Junior Member
**
 Muted
Offline Offline

Posts: 35

Thank You
-Given: 13
-Receive: 17


« on: June 17, 2012, 02:15:35 14:15 »

hi
my question is that:
we have a constant that we want to store in program memory.is this true:

Code:
const char c="hi";
char a;
a=c;
printf("a is %S",c);
and similar to it for eeprom data:
Code:
eeprom char c="hi";
a=c;
printf("a is %S",c);
Logged

C++ is designed to give the programmer choice, even if this makes it possible for the programmer to choose incorrectly
metal
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2018

Thank You
-Given: 514
-Receive: 477


Top Topic Starter


« Reply #1 on: June 17, 2012, 11:15:13 23:15 »

Section "3.5.2 Variables in Data Space Memory" states:

Most variables are ultimately positioned into the data space memory. The exceptions are non-auto variables which are qualified as 'const', which are placed in the program memory space, or 'eeprom' qualified variables.

But concerning EEPROM, the story is a bit different. Look inside XC compiler user's guide: "3.5.5 Variables in EEPROM". This section is more than enough to give you understanding on how to deal with EEPROM. We are talking about PIC18. Also, read "3.4.8.4 EEPROM TYPE QUALIFIER", you will notice that the 'eeprom' type qualifier is recognized by the compiler for baseline and mid-range devices only. If the --STRICT option is used, this qualifier is changed to __eeprom. So you have to stick to things you are going to read in "3.5.5 Variables in EEPROM" when working with PIC18, hence you will have to use __EEPROM_DATA() macro that is explained in "3.5.5.1 EEPROM INITIALIZATION".

Tha manual can be found in your installation folder:
C:\Program Files\Microchip\xc8\v1.00\docs\manual.pdf



P.S. I tried eeprom qualifier with PIC12F675 and still XC8 compiler could not recognized it and issues errors 195 and 312. On PIC18F458 I tried __EEPROM_DATA() macro, and eeprom read and write functions, they worked successfully.
Logged

nothing to say..
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC