#1743 PIC14: data in EEPROM memory handled incorrectly

open
nobody
PIC14
5
2013-07-16
2011-01-16
Anonymous
No

In the SDCC 2.5.x branch I could declare a variable like

const unsigned char at 0x2100 var=0x1c;

...and it would put that variable into nonvolatile data memory.

Now, with sdcc 3.0.1 built from CVS, it does something strange: It treats it like an array in CODE MEMORY, adding 'retlw' instructions in this inappropriate place.

Complete sample code:

const unsigned char __at 0x2100 eedata=0x1c;

void main(void)
{ while(1); }

Compiled with:

sdcc --use-non-free -mpic14 -p16f628a eepromwtf.c

sdcc --version
SDCC : mcs51/gbz80/z80/ds390/pic16/pic14/TININative/ds400/hc08 3.0.1 #6113 (Jan 15 2011) (Linux)

Unexpected result in ASM:

;--------------------------------------------------------
; initialized data
;--------------------------------------------------------
ID_0039_eepromwtf_0 code 0x2100
_eedata
retlw 0x1c

Error messages: None, though the malformed ASM produces a warning, to wit:

eepromwtf.asm:72:Warning [220] Address exceeds maximum range for this processor.

Discussion

  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2011-01-16

    Update: It generates code correctly when the variable has the __data keyword. I somehow thrashed for hours trying to adapt existing code without discovering that, I suppose the code I was fixing was too complicated.

    All the same this is a behavior change. Getting EEPROM data into C code properly is something I'd worked out through trial and error, and I never did find proper documentation describing the process -- I was convinced the PIC14 port didn't even look at __data specifiers and the like, let alone implement them. Just a little note somewhere about a proper way to do this that's expected to stay proper would be great.

     
  • Maarten Brock

    Maarten Brock - 2011-09-16
    • summary: data in EEPROM memory handled incorrectly --> PIC14: data in EEPROM memory handled incorrectly
     
  • Philipp Klaus Krause

    • Category: --> PIC14
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks