Variable at Absolute Address & NO:INIT

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Variable at Absolute Address & NO:INIT

1,233 Views
sebasira
Senior Contributor I

Hi to all of you!

 

I'm working with CW4.6 and HCS12. I decide to place some EEPROM variables at absoulte addresses using @. Before that they were at a segment with NO_INIT.

 

Now, even if I have the variable within this segment (with pragma) it is initialized with 0x00 and I want it to be 0xFF. Is there anyway I can do that?

 

If possisble I don't what to do this:

 

const dword EEPROM_VAR @0x2000 = 0xFFFFFFFF

 

Thanks!

Labels (1)
0 Kudos
Reply
8 Replies

914 Views
kef
Specialist I

Removing const should help.

0 Kudos
Reply

914 Views
sebasira
Senior Contributor I

Sadly... it just the same....

0 Kudos
Reply

914 Views
kef
Specialist I

Looks like it is improved in newer versions of CW. I'm looking into generated S19 file, CW5.1.  Using const and @, but no =initializer, I see zeros at @-address in S19 file. Without const 1) no data in S19 file, and 2) starup routine doesn't initialize @-variable.

0 Kudos
Reply

914 Views
sebasira
Senior Contributor I

Well, I guess I would have to manually initialize each of them or maybe create another file whit all the EEPROM variables together.

Thanks!

PS: If you figure out another solution, please tell me.

0 Kudos
Reply

914 Views
kef
Specialist I

If you just don't want EEPROM data to be overwritten by uploading new code using bootloader, then you may edit BBL file to make EEPROM data not included in generated S19 file. In fact you may make BBL producing several S19 files, for example one with EEPROM data, another one without, 3rd one without bootloader S-lines etc. All S19 files will be produced in one build project click.

914 Views
sebasira
Senior Contributor I

Wow! That's new to me! Moreover, I always need to make 2 builds just to get a release with and without bootloader. And we also have about 10 different compilation parameters so I needed 20 different builds.

I'm not sure about what I'm going to say, but if I put the NO_INIT attribute to the segment (PAGE_EEPROM) no s19 lines are generated for that memory sector. I guess if this is not right then, the bootloader will overwrite my EEPROM data and that's not happenning.

Can you explain me how to do that? I think you're talking about the "burner.bbl" file, right?

Thank you! Thank you very much!

SebaS

0 Kudos
Reply

914 Views
kef
Specialist I

I don't remember how do default CW4.6 bbl files look like and if they are as complicated as CW5 files. BTW I looked into CW5 S12XD bbl file and noticed that everything from addresses below 0x4000 is not included in generated S19 files. See attached.

4 bold lines below will take code at 0x2000..0x20FF from project.abs file and put it to project.abs.s19 file with S-records addresses 0x3000..0x30FF.

OPENFILE "%ABS_FILE%.s19"

format = motorola

busWidth = 1

SRECORD=Sx

len = 0x100

origin = 0x2000

destination = 0x3000

SENDBYTE 1 "%ABS_FILE%"

CLOSE

So just try to find the origin= and len= that correspond to to EEPROM addresses, reduce len and increase origin and destination to make EEPROM addresses not included in S19 file.

To have more files generated just copy everything from line  OPENFILE xxx  to line CLOSE  and paste it at the end of bbl file:

OPENFILE "%ABS_FILE%.s19"

...

CLOSE

OPENFILE "%ABS_FILE%2.s19"

...

CLOSE

This will produce two identical s19 files. Modify bbl lines in one of OPENFILE-CLOSE block to make the different.

914 Views
sebasira
Senior Contributor I

Thanks Kef!

I'm thinking that this won't help me. My project has some conditionals on the .prm which depends on the compilation and if it has or not bootloader. So I think I can't use it.

Anyway, I'll take it in account for the next time.

For now, I'll stick with the previous plan of having a separate file with EEPROM variables

As always, thank you very much!

Best Regards!

SebaS

0 Kudos
Reply