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 CCS Technical Support

Trouble understanding write_program_memory() function

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



Joined: 08 Sep 2003
Posts: 492
Location: India

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

Trouble understanding write_program_memory() function
PostPosted: Thu Mar 12, 2015 7:47 am     Reply with quote

Hi,

I am trying to develop a bootloader for my project. I am unable to understand how the write_program_memory function works. I have read the help file and the loader.c but I cannot understand how to write a word to the program memory.

For example I would like to write the following words

EF52 F000 EF05 F000

But instead of the above words I get mostly zeroes (using the MPLAB sim)

Please help...

thanks
a
jeremiah



Joined: 20 Jul 2010
Posts: 1349

View user's profile Send private message

PostPosted: Thu Mar 12, 2015 7:57 am     Reply with quote

You need to provide:
Chip#
Compiler Rev#
Small compilable code that can be copy/pasted by others to test out.

A lot of it is going to depend on what chip in particular and how you are using write_program_memory(). The general gist is if you meet all the chip specific requirements, then it will write that data to memory and possibly erase the page (depending on the address you supply).

The info you have given thus far is insufficient for a solid answer without us guessing and hoping to get it right.
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Thu Mar 12, 2015 9:09 am     Reply with quote

As a comment though, I can't think of any PIC that would accept those words in it's program memory.....

PIC16 - 14bits wide
PIC24 - 24bits wide

Remember that in each case these words are sent as byte or 16bit word 'pieces', so every fourth byte of the PIC24 memory is 'N/A', while the top two bits of every alternate byte of the PIC16 memory is similarly N/A. etc..
Also remember that writing to the first byte of a page, erases the whole page.


Last edited by Ttelmah on Thu Mar 12, 2015 12:48 pm; edited 1 time in total
arunb



Joined: 08 Sep 2003
Posts: 492
Location: India

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

RE:
PostPosted: Thu Mar 12, 2015 9:53 am     Reply with quote

sorry I forgot to mention...

I am using 18F4550 mcu, with PCH compiler 4.073

thanks
a
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Thu Mar 12, 2015 12:47 pm     Reply with quote

Your compiler version is very early for V4. It was one that definitely still had problems, and things like the program memory function, may well have problems.....
What address are you trying to write to?.
It needs to start on a 64byte boundary. Say 0x7FC0.
You need a 32byte array, and load this with the data. Then write the array.
You can then do a second 32byte write to the second half of the block.

Understand that an erased bit, is '1'. When you write a bit you can set it to '0'. If you write over a byte that is not erased, more and more bits will go to '0'. So if you had 0x30, and wrote 0xCF, the result would be 0. If you are trying to write to anywhere but the start of a block, this will be what you see....
arunb



Joined: 08 Sep 2003
Posts: 492
Location: India

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

re
PostPosted: Fri Mar 13, 2015 1:07 am     Reply with quote

thanks for the help.

I managed to solve the problem, I used an int array in the function, as you had mentioned a 32 bit array is required for this.

Now however I have to figure out how the loader.c program works......

thanks
a
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