View previous topic :: View next topic |
Author |
Message |
moutinho
Joined: 12 May 2005 Posts: 31 Location: BRAZIL
|
Does the ccs function write_program_memory() work??? |
Posted: Thu May 12, 2005 2:38 pm |
|
|
Hi,
I have implemented the following code:
int8 data[2];
data[0] = 0x0;
data[1] = 0x1;
erase_program_eeprom(0x1000);
write_program_memory(0x1000, data, 2);
I have checked Program Memory windows and notice the address
0x1000 still kept NOP (0x0000) value.
thanks,
Andre |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Ttelmah Guest
|
|
Posted: Fri May 13, 2005 1:59 am |
|
|
Also add the comment that it is very important not to have any interrupts running when you call the write.
Best Wishes |
|
|
kometen
Joined: 12 Oct 2003 Posts: 13
|
|
Posted: Fri May 13, 2005 4:37 am |
|
|
Yes, it works fine for me with e.g. the 18F452 PIC.
Remember when you use the function that you
must use pointer to the variable
The correct code is:
write_program_memory(0x1000, &data, 2);
Remember to upload the program memory, otherwise you wont see the data in the program memory window.
Check it with
read_program_memory(0x1000, data, 2);
Good luck
Poul |
|
|
moutinho
Joined: 12 May 2005 Posts: 31 Location: BRAZIL
|
|
Posted: Fri May 13, 2005 7:31 am |
|
|
PCM programmer wrote: |
HI,
>1. What is your PIC ?
PIC18F6720
>2. What is your version of the compiler ?
3.206
>3. I guess you must be running this in the simulator,
>so the version of MPLAB will also be important.
>It may not work in the simulator. For example,
>look at some of the articles about this problem
>on the Microchip forum:
Ok, Thanks
>http://forum.microchip.com/tm.asp?>m=86239&mpage=1&key=program+memory&anchor#86260
>http://forum.microchip.com/tm.asp?>m=80348&mpage=1&key=program+memory&anchor#80348
>Just as a general rule, never trust that any hardware process
>will work in the simulator. Always assume the simulator
>is flakey, rather than the compiler. It's more likely.
>Then check the Microchip forum. |
|
|
|
moutinho
Joined: 12 May 2005 Posts: 31 Location: BRAZIL
|
|
Posted: Fri May 13, 2005 8:05 am |
|
|
Hi,
The data variable is declared as
int8 data[32];
So, when I call
write_program_memory(0x1000, data, 2);
The pointer of data is passed to the function.
If I try compiling as write_program_memory(0x1000, &data, 2) I get a compiler error.
Upload program memory is the same as pressing button "Read target device" ???
Its still not working
Thanks,
Andre
kometen wrote: | Yes, it works fine for me with e.g. the 18F452 PIC.
Remember when you use the function that you
must use pointer to the variable
The correct code is:
write_program_memory(0x1000, &data, 2);
Remember to upload the program memory, otherwise you wont see the data in the program memory window.
Check it with
read_program_memory(0x1000, data, 2);
Good luck
Poul |
|
|
|
moutinho
Joined: 12 May 2005 Posts: 31 Location: BRAZIL
|
|
Posted: Fri May 13, 2005 8:07 am |
|
|
HI,
>1. What is your PIC ?
PIC18F6720
>2. What is your version of the compiler ?
3.206
>3. I guess you must be running this in the simulator,
>so the version of MPLAB will also be important.
>It may not work in the simulator. For example,
>look at some of the articles about this problem
>on the Microchip forum:
Ok, Thanks
>http://forum.microchip.com/tm.asp?>m=86239&mpage=1&key=program+memory&anchor#86260
>http://forum.microchip.com/tm.asp?>m=80348&mpage=1&key=program+memory&anchor#80348
>Just as a general rule, never trust that any hardware process
>will work in the simulator. Always assume the simulator
>is flakey, rather than the compiler. It's more likely.
>Then check the Microchip forum. |
|
|
moutinho
Joined: 12 May 2005 Posts: 31 Location: BRAZIL
|
|
Posted: Fri May 13, 2005 8:08 am |
|
|
Hi,
Also tried
disable_interrupts(GLOBAL);
erase_program_eeprom(0x1000);
write_program_memory(0x1000, data, 2);
read_program_memory(0x1000, data_read, 2);
enable_interrupts(GLOBAL);
Thanks,
Andre |
|
|
Ttelmah Guest
|
|
Posted: Fri May 13, 2005 8:25 am |
|
|
moutinho wrote: | Hi,
Also tried
disable_interrupts(GLOBAL);
erase_program_eeprom(0x1000);
write_program_memory(0x1000, data, 2);
read_program_memory(0x1000, data_read, 2);
enable_interrupts(GLOBAL);
Thanks,
Andre |
You are still passing the value, not the _address_ of the value.
Best Wishes |
|
|
mrbmcg
Joined: 02 Jun 2005 Posts: 2
|
|
Posted: Thu Jul 07, 2005 7:59 am |
|
|
In my experience the CCS debugger won't modify the ROM window when you write to it and it just remains the same.
Best way to check is to read it back using read_program_memory() into some RAM variable and check it in the debugger.
As good as the debugger is for many things it's still a long way off being bulletproof IMHO.
Still much better than any of the competition, again IMHO |
|
|
|