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

write_program_memory

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



Joined: 30 Mar 2008
Posts: 109
Location: New Jersey

View user's profile Send private message

write_program_memory
PostPosted: Thu Jan 26, 2017 9:51 am     Reply with quote

I should have started a new thread instead of posting some or the following at the end of the thread about XOFF not working.

I could not really figure out if SIOW was working or not and it was too hard to troubleshoot so I wrote my own send routines to send the hex file. Now I have control of both ends and it is a little easier to work on. I can send the whole hex file and I get an ACK for every line, but the program will not run. I can run the loader in the debugger and break after it has received the first line, and is ready to write the data to program memory. I can see the address of the first write (0x500 as expected), and the data is correct. But when the write_program_memory function is called, nothing is written.

I am basing that on the fact that I can see address x500 in the ROM window of the debugger. It has a branch to its own address there as expected. When I write to that address the ROM values shown do not change. Just to be sure I changed the address to x400 (where there is all zeroes) and still nothing was changed. I wondered if maybe the ROM window does not get updated when it is changed, so I reset the debugger to the start and traced the code with the program button not pushed. Sure enough, it ends up at address x500 and then continually branches to that address. So nothing was written.

Next I studied the data sheet for the PIC18F4680 again and I think I see the problem. According to the compiler manual:
Quote:
For chips where
getenv(“FLASH_ERASE_SIZE”) = getenv(“FLASH_WRITE_SIZE”)
write_program_eeprom() - Writes 2 bytes, no erase is needed.
write_program_memory() - Writes any number of bytes, bytes outside the range of the write block are not changed. No erase is needed.


For the 4680, both flash erase and flash write are 64 bytes, but the data sheet clearly indicates that program memory must be written in 64 byte increments. Looking at the code generated by the compiler (V5.064) it is trying to read and then write individual bytes. Also the datasheet shows code to write to flash memory and it is totally different from what the compiler generated.

So I believe I have found a compiler error. Has anyone else seen this or can confirm my conclusion?

Thanks, Russ
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jan 26, 2017 9:22 pm     Reply with quote

Quote:

Looking at the code generated by the compiler (V5.064) it is trying to
read and then write individual bytes.

Post a little test program (complete) so we can look at the .LST file.
russk2txb



Joined: 30 Mar 2008
Posts: 109
Location: New Jersey

View user's profile Send private message

PostPosted: Tue Jan 31, 2017 9:44 am     Reply with quote

Hi PCM. Sorry for the delay - got busy with another project for a few days. But it turns out that write to program memory does work. I reorganized the loader so it always starts the write on a 64 byte boundary and it does work. I still don't understand why the compiler generated code is so different from the example code given in the PIC data sheet, but I can't argue with success.

Now there is another problem, but I will start a separate thread for that.

Thanks, much - Russ
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