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 CCS Technical Support

Store number in rom and than read it.

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



Joined: 07 May 2011
Posts: 40
Location: Bulgaria

View user's profile Send private message

Store number in rom and than read it.
PostPosted: Wed Mar 05, 2014 2:31 am     Reply with quote

I use
#rom #ROM 0x3FF0={1234} to store 04D2 to rom address 0x3FF0.

Hot to read 0x3FF0 address and if number is the same to perform some operation?
Ttelmah



Joined: 11 Mar 2010
Posts: 19546

View user's profile Send private message

PostPosted: Wed Mar 05, 2014 3:21 am     Reply with quote

Question one, 'why bother'....

You do realise that if you declare a variable as 'const', it is stored in ROM for you, and can be used as a normal variable.
So:
Code:

const int16 ROM_val=1234;
   
    if (ROM_val==1234)
       //do something....


'1234' is actually stored for you in ROM.

However if you 'must' store at a specific location, then use 'read_program_eeprom'

So:
Code:

#rom #ROM 0x3FF0={1234}   

    int16 ROM_val;
    ROM_val=read_program_eeprom(0x3FF0);
    if (ROM_val==1234)
       //do something


But _caveat_. What can be stored at a location depends on your chip. With a PIC16, each ROM 'word' is only 14 bits wide. So could store 0x3FFF, but not 0x7FFF.
Then some older chips _cannot_ read their own ROM. They just don't have the instructions to do this. If you code as the 'const', the compiler will instead generate a _program_ to return the correct values on such chips. If you use #ROM, it cannot be retrieved in such chips.
tonkostz



Joined: 07 May 2011
Posts: 40
Location: Bulgaria

View user's profile Send private message

PostPosted: Wed Mar 05, 2014 4:18 am     Reply with quote

Thanks Ttelmah!
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