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 CCS Technical Support

Does the ccs function write_program_memory() work???

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



Joined: 12 May 2005
Posts: 31
Location: BRAZIL

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

Does the ccs function write_program_memory() work???
PostPosted: Thu May 12, 2005 2:38 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu May 12, 2005 3:53 pm     Reply with quote

1. What is your PIC ?

2. What is your version of the compiler ?

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:

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.
Ttelmah
Guest







PostPosted: Fri May 13, 2005 1:59 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri May 13, 2005 4:37 am     Reply with quote

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

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

PostPosted: Fri May 13, 2005 7:31 am     Reply with quote

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

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

PostPosted: Fri May 13, 2005 8:05 am     Reply with quote

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 Sad


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

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

PostPosted: Fri May 13, 2005 8:07 am     Reply with quote

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

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

PostPosted: Fri May 13, 2005 8:08 am     Reply with quote

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







PostPosted: Fri May 13, 2005 8:25 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jul 07, 2005 7:59 am     Reply with quote

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