|
|
View previous topic :: View next topic |
Author |
Message |
naughty_mark
Joined: 29 Aug 2012 Posts: 97
|
write_program_memory doesn't work properly |
Posted: Sun Sep 16, 2012 5:00 pm |
|
|
Dear All,
I met a problem with write_program_memory. I am using MPLAB with CCS v4.133 and work with dsPIC33EP256MU814
Code: |
write_program_memory(ProgAddress,HexRecordSt.Hex_Data, HexRecordSt.RecDataLen);
|
The ProgAddress is 0x10000, and HexRecordSt.Hex_Data is pointer pointing to the start address of an array. and HexRecordSt.RecDataLen is a 16bits word which should be less than 512.
The hex I write it in like
Code: |
:10000000C1E8A8000E2EEF001E2EEF002E2EEF00EE
:100010003E2EEF004E2EEF005E2EEF006E2EEF0014
:100020000FF82600F0FF260020A0B7000000000017
|
however, after I write in those data in and read them out, it is
Code: | :
:10000000E8A800002EEF00002EEF00002EEF000009
:100010002EEF00002EEF00002EEF00002EEF00006C
:10002000F8260000FF260000A0B700000000000036
|
as you can see the first byte of every segment is replaced by 0x00. I have 0x00 at the forth byte and did many times debugging to make sure that the pointer points to the correct address, and the length is right.
Anyone has idea about it?
Thanks a lot
EDIT: I tried a test code which just write 512 byte to 0x10000, it was correct, the only different between the test code and my program is the test code is from the beginning of the string to write in, and my program start address is the fifth byte of the string.
EDIT: never mind, guys. I transfer the data to a new array which will be read from the 1st byte of the array, and it works. It looks this function has many bugs. Be careful to use it |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1349
|
|
Posted: Mon Sep 17, 2012 6:15 am |
|
|
I may be misunderstanding what you are saying, but if just transferring the data from one array to another fixes your issue, then it wouldn't be the write_program_memory() function that is at issue as the transfer happens outside the function.
It would be easier to tell if you posted the code for reading, the code for writing, and the code that defines the type for HexRecordSt. |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Mon Sep 17, 2012 7:31 am |
|
|
I'm not aware of a bug in write_program_memory(). Without a compilable example that can be
verified for correctness, I rather assume an error in your code. |
|
|
|
|
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
|