CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

migrating from Hitech, how to preload EEPROM data?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
pe1icq



Joined: 29 Aug 2005
Posts: 12

View user's profile Send private message

migrating from Hitech, how to preload EEPROM data?
PostPosted: Mon Aug 29, 2005 4:51 pm     Reply with quote

I'm migrating some code that is used with the Hitech PICCompiler.

In an include file there is some code that preloads the EEPROM with some data. It looks like this.
Code:

#asm
        psect   eeprom_data,class=EEDATA,delta=2

        db      'A'<<1, 'P'<<1, 'E'<<1, 'R'<<1, 'X'<<1, 'Q'<<1, '0'<<1
        db      'N'<<1, 'O'<<1, 'C'<<1, 'A'<<1, 'L'<<1, 'L'<<1, '0'<<1
        db      'R'<<1, 'E'<<1, 'L'<<1, 'A'<<1, 'Y'<<1, ' '<<1, '0'<<1
        db      'W'<<1, 'I'<<1, 'D'<<1, 'E'<<1, '2'<<1, ' '<<1, ('2'<<1) + 1
 #endasm


How would I convert this for use with the CCS PCM C Compiler?

Thanks for your help.

//Arno
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Mon Aug 29, 2005 5:17 pm     Reply with quote

Search for #rom in this forum.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Aug 29, 2005 5:25 pm     Reply with quote

(But Mark, I already typed this in -- might as well post it).

#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)

#rom 0x2100 = {
'A'<< 1, 'P'<< 1, 'E'<< 1, 'R'<< 1, 'X'<< 1, 'Q'<< 1, '0'<< 1, \
'N'<<1, 'O'<<1, 'C'<<1, 'A'<<1, 'L'<<1, 'L'<<1, '0'<<1, \
'R'<<1, 'E'<<1, 'L'<<1, 'A'<<1, 'Y'<<1, ' '<<1, '0'<<1, \
'W'<<1, 'I'<<1, 'D'<<1, 'E'<<1, '2'<<1, ' '<<1, ('2'<<1) + 1
}

//======================================
main(void)
{


while(1);
}
MikeValencia



Joined: 04 Aug 2004
Posts: 238
Location: Chicago

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Mon Aug 29, 2005 5:32 pm     Reply with quote

In case you were wondering where he got "0x2100" from, then you have to read the small paragraph in section 2.2 of the following document:

http://ww1.microchip.com/downloads/en/DeviceDoc/39025f.pdf

If you're working with something other than the '877, then you similiarly have to download the corresponding document for that particular chip. "0x2100" is not common to other PICs.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Mon Aug 29, 2005 7:26 pm     Reply with quote

PCM programmer wrote:
(But Mark, I already typed this in -- might as well post it).

#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)

#rom 0x2100 = {
'A'<< 1, 'P'<< 1, 'E'<< 1, 'R'<< 1, 'X'<< 1, 'Q'<< 1, '0'<< 1, \
'N'<<1, 'O'<<1, 'C'<<1, 'A'<<1, 'L'<<1, 'L'<<1, '0'<<1, \
'R'<<1, 'E'<<1, 'L'<<1, 'A'<<1, 'Y'<<1, ' '<<1, '0'<<1, \
'W'<<1, 'I'<<1, 'D'<<1, 'E'<<1, '2'<<1, ' '<<1, ('2'<<1) + 1
}

//======================================
main(void)
{


while(1);
}


Yeah, that's cause you're nicer than I ;) I like for them to do some of the work Smile
pe1icq



Joined: 29 Aug 2005
Posts: 12

View user's profile Send private message

PostPosted: Tue Aug 30, 2005 6:45 am     Reply with quote

Hi Guys,

Thanks for your replies.

I had looked at the #rom directive, but it seemed to me that this could not be used on a 16f628a.

The 16f87x series have eeprom logically mapped to 0x2100 and up.
But the 16f628 has eeprom indirectly addressed via some Special Function Registers.

Any thoughts on that?

Thanks.

//Arno
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Tue Aug 30, 2005 7:12 am     Reply with quote

It should still work. Did you try it? Look at the other datasheets. They have the same blurb.

Last edited by Mark on Tue Aug 30, 2005 7:13 am; edited 1 time in total
pe1icq



Joined: 29 Aug 2005
Posts: 12

View user's profile Send private message

PostPosted: Tue Aug 30, 2005 8:34 am     Reply with quote

I didn't really try yet. Before I do I need to rewrite some of the other Hitech specifics. Hopefully I get to it later tonight.

I'll post the results.

//Arno
Ttelmah
Guest







PostPosted: Tue Aug 30, 2005 9:01 am     Reply with quote

pe1icq wrote:
Hi Guys,

Thanks for your replies.

I had looked at the #rom directive, but it seemed to me that this could not be used on a 16f628a.

The 16f87x series have eeprom logically mapped to 0x2100 and up.
But the 16f628 has eeprom indirectly addressed via some Special Function Registers.

Any thoughts on that?

Thanks.

//Arno


The original 16f628 programming datasheet (and those for some of the other similar chips), does not mention this. However the current versions, now specifically say that EEPROM data should be included at address 0x2100. As you say, these chips do not actually map the EEPROM into this area (in fact the whole block from 0x2000 to 0x3FFF, is reserved for the configuration data, which only really occupies the first few bytes), but MicroChip, have logically decided to make the programming spec the same, and require programmers to handle the mapping.
How the EEPROM mapping is done, is a MicroChip decision, not a CCS one. CCS simply allow you to write data to any address using the ROM directive.

Best Wishes
pe1icq



Joined: 29 Aug 2005
Posts: 12

View user's profile Send private message

PostPosted: Sat Sep 03, 2005 7:33 am     Reply with quote

The #rom directive was indeed what I needed.
Also for use with the 16f628a I can define eeprom data at addresses 0x2100 and up. And then read them back using read_eeprom() starting at address 0x00.

To all who replied, thanks for your help.

//Arno
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group