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

Saving password data to flash

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



Joined: 14 May 2004
Posts: 330

View user's profile Send private message

Saving password data to flash
PostPosted: Fri Aug 05, 2005 6:22 pm     Reply with quote

Hi,

I am starting to implement a security scheme to a previous project and thinking about a 4 or 6 digit password to unlock functions.

The internal eeprom is already full, so some bytes of flash will be used.

What method you advise me to use? #org and write flash, label_adress, other way?

I am not willing to write all possibilities and try them as I am used to do because I don't have much time.

Thank you.
Ttelmah
Guest







PostPosted: Sat Aug 06, 2005 2:39 am     Reply with quote

The normal method is to use #ROM, which does most of the work for you. So if (for instance), you have something like:
Code:

#define PASSWORD_ADDRESS (0x7FF0)
//This will depend on your chip, and where there is space to use

#ROM PASSWORD_ADDRESS = {"This is a test"}


This will generate a segment, at the specified address, containing the required data.
Then you can read this insde the code with
'read_program_eeprom(PASSWORD_ADDRESS)'

and just add an offset to password address to step through the data, and write new values to it, with 'write_program_eeprom'.
Remember that on 16bit parts (the 18 family), each address will contain two bytes, returned as a 16bit value.

Best Wishes
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sat Aug 06, 2005 7:45 am     Reply with quote

I've found the #ROM statement in the 16-bit parts (PIC18) to be a bit confusing. You have the following options:

// Example to set words:
#ROM 0xF00000 = {1, 2, 3, 4, 5}

// Example to set bytes:
#ROM int8 0xF00000 = {1, 2, 3, 4, 5}

// Example to set a string of bytes:
#ROM 0xF00010 = {"12345"}
future



Joined: 14 May 2004
Posts: 330

View user's profile Send private message

PostPosted: Sat Aug 06, 2005 1:06 pm     Reply with quote

Great! The solution looks simple.

But, how should I do to let the compiler choose an empty address?

The last 100 words of flash is being used by the tiny bootloader and the first 10k bytes by the firmware.

Something like the first page after the end of the firmware may be fine.

If this address is at the start of the page, the erase before write will be handled by the compiler, one thing less to worry.
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