View previous topic :: View next topic |
Author |
Message |
respected
Joined: 16 May 2006 Posts: 95
|
http command and array |
Posted: Fri Oct 12, 2018 6:50 am |
|
|
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: 19513
|
|
Posted: Fri Oct 12, 2018 6:54 am |
|
|
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
|
|
Posted: Fri Oct 12, 2018 7:01 am |
|
|
Already first one don't work.
How correct to mistake? Maybe i should write in to ROM. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Fri Oct 12, 2018 7:21 am |
|
|
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
|
|
Posted: Fri Oct 12, 2018 7:38 am |
|
|
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: 297
|
|
Posted: Fri Oct 12, 2018 1:06 pm |
|
|
To change program memory during runtime you do need READ_PROGRAM_MEMORY and WRITE_PROGRAM_MEMORY. |
|
|
|