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

http command and array

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



Joined: 16 May 2006
Posts: 95

View user's profile Send private message

http command and array
PostPosted: Fri Oct 12, 2018 6:50 am     Reply with quote

What is the difference I don't understand:

Code:
char remote_ip[16]="192.168.1.20";
HttpClientSetHostNameROM((rom char*)remote_ip);


or

Code:
HttpClientSetHostNameROM((rom char*)"192.168.1.20");
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Fri Oct 12, 2018 6:54 am     Reply with quote

char remote_ip[16]="192.168.1.20";

Here 'remote_ip' is a variable stored in RAM.

This is then cast to have behave as if it is in ROM. (not even sure that this can work....).

HttpClientSetHostNameROM((rom char*)"192.168.1.20");

Here "192.168.1.20" is a constant stored in ROM.
respected



Joined: 16 May 2006
Posts: 95

View user's profile Send private message

PostPosted: Fri Oct 12, 2018 7:01 am     Reply with quote

Already first one don't work.

How correct to mistake? Maybe i should write in to ROM.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Fri Oct 12, 2018 7:21 am     Reply with quote

If the function expects the data to be in ROM, it can't accept data in RAM.

This is the old 'Harvard architecture' issue.

The PIC uses Harvard architecture. Completely separate RAM and ROM data spaces. Separate address busses and data busses. There is an address 0 in ROM, and another in RAM.

Now the:

char remote_ip[16]="192.168.1.20";

Creates an array that is copied from ROM to RAM at boot, and is stored in RAM.

remote_ip is the address of this in RAM.

Casting this to be 'seen' as a rom pointer, stops the compiler from complaining, but doesn't change the fundamental problem that the address (if used as a ROM address), will not point to the actual data.

Code:

rom char remote_ip[16]="192.168.1.20";
HttpClientSetHostNameROM(remote_ip);


Would create the array in ROM, and hand the address of this to the function, but it is a constant, not something that can be edited.

One question. What chip are you using?.
respected



Joined: 16 May 2006
Posts: 95

View user's profile Send private message

PostPosted: Fri Oct 12, 2018 7:38 am     Reply with quote

Yes. It works now.

Before i used program memory. But READ_PROGRAM_MEMORY and WRITE_PROGRAM_MEMORY command.

I learned a new knowledge.

Can i change ROM data while PIC is working?
guy



Joined: 21 Oct 2005
Posts: 291

View user's profile Send private message Visit poster's website

PostPosted: Fri Oct 12, 2018 1:06 pm     Reply with quote

To change program memory during runtime you do need READ_PROGRAM_MEMORY and WRITE_PROGRAM_MEMORY.
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