Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problems using C18 compiler

Status
Not open for further replies.

leomecma

Full Member level 5
Full Member level 5
Joined
Jun 17, 2005
Messages
244
Helped
14
Reputation
28
Reaction score
1
Trophy points
1,298
Location
Brasil
Activity points
3,933
startup e2prom c18

Hi,

I was having some problems on use ROM qualifier, I need declare a struct, and this struct should be flash resident. I try something like this:


This forms works, but it's reside in RAM:

typedef struct{
byte cod_prod;
byte ano_fabr;
byte sem_fabr;
byte seq_num_h;
byte seq_num_l;
}TEMP_SERIAL;

TEMP_SERIAL serial_number;

void TempWriteSerial (void)
{
serial_number.cod_prod = dataPacket._byte[1];
serial_number.ano_fabr = dataPacket._byte[2];
serial_number.sem_fabr = dataPacket._byte[3];
serial_number.seq_num_h = dataPacket._byte[4];
serial_number.seq_num_l = dataPacket._byte[5];
}

// End RAM

Try to put data in ROM

struct TEMP_SERIAL{
byte cod_prod;
byte ano_fabr;
byte sem_fabr;
byte seq_num_h;
byte seq_num_l;
};

// declare elements of struct type

rom struct TEMP_SERIAL serial_number;
rom struct TEMP_SERIAL *serial_number;

The basic diffence off them are the member acess form "." ou "->" I try the forms below too, but doesn' work, and anyone give error or warnings

rom struct TEMP_SERIAL rom serial_number;
rom struct TEMP_SERIAL rom *serial_number;

I just need received an array of data from USB (dataPacket) and save it on my struct, but I wanna this data lives on ROM, because I need save RAM and this data are configuration data, and changes remotely. Read this configuration data from ROM will be doing sometimes. What's the correct form to do it?

leomecma
leomecma
 

write to flash c18

I am not quite clear on what you are trying to do but If I understand correctly you want to save config data in a struct?.

The best way to do this is to save the struc in EEPROM as an array of bytes.

When you get an array of bytes save it to a RAM struct and then write it out to the EEPROM as a sequence of bytes, then on startup read the eeprom struc back into ram.
 

c18 writing to rom

I don't have EEPROM memory on this device. In Microchip forum a person asnwer me, that is not possible do I want. I was created a write flash routine to do it. For read I just declare a pointer to rom.

leomecma
 

c18 pointer to ram address

just keep the fixed data as fixed data in rom

declare as #define s

then build the struct at run time

then at up time this info can be changed provided
you pass the defined data to variables

changing it in rom is hard
to do this
yes you must write a flash routine

1} not to overwrite your program
2} update just a few byte's in the rom

its a matter to modifiy a boot loader routine or similar to get the data fromusb you wish to change

this should be done by reseting the mcu to flash mode change the data and reboot it


a pic can reboot itself with commands
or you can toggle the reset pin from an i/o adding a cap 1uf to get some time

appart from this maybe i2c eeprom or three wire or something is needed to be added

i made a security check routines that scanned all the pins of the micro for the right levels
then booted it provided it had been init properly

if you tampered with the chip
the next time you booted it it would erase its self but just left the boot block
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top