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

Floating Point Numbers in #ROM Statement

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



Joined: 27 Jan 2004
Posts: 12

View user's profile Send private message

Floating Point Numbers in #ROM Statement
PostPosted: Fri Jul 21, 2006 7:34 am     Reply with quote

I understand what the #ROM statement is used for and how to place integers at compliation time. I am using a PIC18F242 and need to place 2 floating point numbers in the internal eeprom when the chip is programed.

I have 5 numbers to store using the #ROM statement.

#1 - 5 in location 0
#2 - 2 in location 1
#3 - 10.0 in location 2,3,4,5
#4 - 100.0 in location 6,7,8,9
#5 - 15 in location 10

#rom int 0xf00000={5,1,?,?,?,?,?,?,?,?,10}

Thanks for taking a look at my question...
epideath



Joined: 07 Jun 2006
Posts: 47

View user's profile Send private message

PostPosted: Fri Jul 21, 2006 8:52 am     Reply with quote

You can do this. It won't allow you to specify where in memory to put it. but it will allocate it in the Program Rom vs. RAM.

Not sure if that will meet your needs or not.


float const SomeValue[] = {1.0,2.0,3.0};


Hope this helps
Ttelmah
Guest







PostPosted: Fri Jul 21, 2006 12:00 pm     Reply with quote

Er. I'm sorry 'epideath', but you are wrong. The ROM statement as posted, will work exactly as he wants to put a number in the EEPROM.
In the CCS directory, there is a little 'tool, called 'Pconvert.exe'. This tells you what bytes represent a float, so type in the '10.0' into the float window, and the 'hex' widow, will give the pattern '82200000', which is what needs to go in place of the first for question marks. I'll leave the poster to work out the next four bytes.

Best Wishes
whmeade10



Joined: 27 Jan 2004
Posts: 12

View user's profile Send private message

PostPosted: Fri Jul 21, 2006 1:06 pm     Reply with quote

Thanks for your quick reply I will give it a try tonight.
epideath



Joined: 07 Jun 2006
Posts: 47

View user's profile Send private message

PostPosted: Fri Jul 21, 2006 2:37 pm     Reply with quote

Quote:
Er. I'm sorry 'epideath', but you are wrong


I didn't say that he couldn't do it this way. I was just giving an alternative. But I also didn't no about the little program to convert the floating point for you.
Ttelmah
Guest







PostPosted: Sun Jul 23, 2006 3:01 am     Reply with quote

The problem is that your 'alternative', won't work.
#ROM, allows you to put a sequence of bytes anywhere in ROM, whether program space, or EEPROM. You can even define the date 'type' to be placed, when working in the program space (int16 or int8 - unfortunately, this doesn't support a 'float' - a real pity..).
The 'const' statement, doesn't just place the data, but generates a 'program' to retrieve the data as well. As such, it only works for the program memory space, and not the EEPROM, and can't be used to put a defined block of data directly 'at' a location in memory, since the header 'program', will result in the actual data being placed a little further on in the memory space than expected. You can define where to put a 'const' (you say that you can't) - since it is a 'program', you use:
Code:

#org 0x1000,0x10ff default
const float fred1[] = {10.0,100.0};
#org default

However what is generated, actually has the 'data' at 0x1014 to 0x101A, with the loader program at 0x1000.

Best Wishes
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