View previous topic :: View next topic |
Author |
Message |
PIC24H
Joined: 02 Mar 2015 Posts: 19
|
Writing multiple lines into program memory |
Posted: Thu Jul 16, 2015 6:03 am |
|
|
Hello. I am using the ex_pcd CCS Bootloader. The bootloader writes line after line into the pic. this takes "a lot" of time. Now I am trying to load about 23 lines, so that it writes a bunch of lines into the program memory at once, so that it dont have to erase and write for each line.
I wrote a routine so that it checks each line in the array to get the checksum etc. I copy all the date of the lines into the data[] Array.
How does the write_program_memory( ) work?
write_program_memory( address, dataptr, count );
I just calculated the address for the first line. As the dataptr the data Array is given. and the count is to total bytes of lines. I cant get it to work :(
Can someone help me? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Thu Jul 16, 2015 7:27 am |
|
|
You do understand that existing code does _not_ erase for each line. It only erases on the first write to the bottom of the page.
Trying to write more than FLASH_WRITE_SIZE bytes at a time, will actually make the code slower. The most efficient size to transfer is defined by this value (the number of write latches that the chip has - write this many bytes, and a single transfer will be used). Make your array this size for best operation.
Be prepared for just how slow the memory actually is. On a chip like the 24FJ256, each row write takes 1.5mSec, while each page erase takes up to 40mSec. You have to erase 4096 pages, and write 32768 rows to fill the chip. Over 4minutes, even without transferring any serial data....
The reason programmers are so much quicker, is they can use the bulk erase, which clears the whole chip. Bootloaders can't do this.... |
|
|
PIC24H
Joined: 02 Mar 2015 Posts: 19
|
|
Posted: Thu Jul 16, 2015 2:05 pm |
|
|
Thanks for your reply Ttelmah.
Ok I'll try to do that. I am trying to reach the speed of the mplab ide. Mplab takes just several seconds to write it to the pic. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Fri Jul 17, 2015 12:34 am |
|
|
The IDE normally programs the chip. Doesn't use the bootloader, so you won't get close to the speed it can manage. |
|
|
|