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

fastest write_program_memory() execution?????

 
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

fastest write_program_memory() execution?????
PostPosted: Tue May 24, 2005 8:21 am     Reply with quote

Hi,

I am implementing a bootloader using
write_program_memory(dest_addr, buffer, size) function.

But the write process seems too slow. What is the size value that leads to the maximum memory transfer rate?

Thanks,
Andre
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Tue May 24, 2005 11:07 am     Reply with quote

That would be a page size but dest_addr should be aligned to page boundaries.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue May 24, 2005 11:38 am     Reply with quote

Also have a look at C:\Program Files\PICC\Drivers\loader.c which uses getenv("FLASH_ERASE_SIZE") to automatically retrieve the flash erase size at compile time.
moutinho



Joined: 12 May 2005
Posts: 31
Location: BRAZIL

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

PostPosted: Tue May 24, 2005 1:48 pm     Reply with quote

Hi,

Why do I need to erase before writing ? I have made a program that simply wrote 0x0 on some address places. It worked fine.


ckielstra wrote:
Also have a look at C:\Program Files\PICC\Drivers\loader.c which uses getenv("FLASH_ERASE_SIZE") to automatically retrieve the flash erase size at compile time.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue May 24, 2005 3:01 pm     Reply with quote

moutinho wrote:
Hi,

Why do I need to erase before writing ? I have made a program that simply wrote 0x0 on some address places. It worked fine.


ckielstra wrote:
Also have a look at C:\Program Files\PICC\Drivers\loader.c which uses getenv("FLASH_ERASE_SIZE") to automatically retrieve the flash erase size at compile time.
Depends on the PIC processor you are using. The newer processors like the PIC18 have larger flash memory but come with the drawback that you can not erase a single byte but only a page of for example 32 bytes. So in order to modify a single byte on those newer processors you have to read an entire page, erase the page and write back the modified page. The CCS function write_program _memory() hides this fact from the user by automatically performing an erase operation when instructed to write a the first address of a page.
moutinho



Joined: 12 May 2005
Posts: 31
Location: BRAZIL

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

PostPosted: Wed May 25, 2005 7:45 am     Reply with quote

Hi,

Thatīs nice, but why the loader.c example uses the erase_program_memory() function ? Just for compatibility reasons with other pics ?

Thanks,
Andre


ckielstra wrote:
moutinho wrote:
Hi,

Why do I need to erase before writing ? I have made a program that simply wrote 0x0 on some address places. It worked fine.


ckielstra wrote:
Also have a look at C:\Program Files\PICC\Drivers\loader.c which uses getenv("FLASH_ERASE_SIZE") to automatically retrieve the flash erase size at compile time.
Depends on the PIC processor you are using. The newer processors like the PIC18 have larger flash memory but come with the drawback that you can not erase a single byte but only a page of for example 32 bytes. So in order to modify a single byte on those newer processors you have to read an entire page, erase the page and write back the modified page. The CCS function write_program _memory() hides this fact from the user by automatically performing an erase operation when instructed to write a the first address of a page.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Wed May 25, 2005 8:37 am     Reply with quote

Quote:
Thatīs nice, but why the loader.c example uses the erase_program_memory() function ? Just for compatibility reasons with other pics ?
Loader.c uses erase_program_memory() for the special situations where you want to write a block of data not starting at a page-starting-address. In this case write_program_memory() wouldn't perform the implicit erase for you.
I think this shows a clumsy design, it would have been better when write_program_memory() just did what the name says, write data and not do an implicit erase. Now the CCS bootloader will corrupt memory when the provided hex-file has the data not in sequential order.
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