View previous topic :: View next topic |
Author |
Message |
moutinho
Joined: 12 May 2005 Posts: 31 Location: BRAZIL
|
fastest write_program_memory() execution????? |
Posted: Tue May 24, 2005 8:21 am |
|
|
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
|
|
Posted: Tue May 24, 2005 11:07 am |
|
|
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
|
|
Posted: Tue May 24, 2005 11:38 am |
|
|
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
|
|
Posted: Tue May 24, 2005 1:48 pm |
|
|
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
|
|
Posted: Tue May 24, 2005 3:01 pm |
|
|
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
|
|
Posted: Wed May 25, 2005 7:45 am |
|
|
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
|
|
Posted: Wed May 25, 2005 8:37 am |
|
|
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. |
|
|
|