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

Relocation of code

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







Relocation of code
PostPosted: Sat Jan 04, 2003 11:22 pm     Reply with quote

Hi,

I use a bootloader in my wireless control applications for firmware upgrade.

The bootloader is run at power up by installing a jump at 0000H and then
return to 0003H after the bootloader is finished.

The current code was compiled using Hi-Tech C and the main source was
relocated to start at 0003H using the following code...

#asm
psect powerup, class=CODE, delta=2
global powerup, start
powerup:
org 0x3
goto start
#endasm

Can someone here advise me how I can accomplish the same effect using CCS
compiler ?

Thanks in advance

Kind regards

David Huisman
___________________________
This message was ported from CCS's old forum
Original Post ID: 10423
PCM programmer



Joined: 06 Sep 2003
Posts: 20260

View user's profile Send private message

Re: Relocation of code
PostPosted: Mon Jan 06, 2003 12:44 pm     Reply with quote

:=Hi,
:=
:=I use a bootloader in my wireless control applications for firmware upgrade.
:=Can someone here advise me how I can accomplish the same effect using CCS
:=compiler ?
--------------------------------------------------------

Apparently with HiTech, you can put code in the first four ROM
words. I don't think CCS has this ability.

There are two ways that I know of, to do a bootloader for CCS.

1. Create an ASM file that has your bootloader code. Burn it
into the PIC (16F87x) with a regular programmer (PicStart+).
This method is used with Shane and Petr's bootloader.
<a href="http://www.microchipc.com/PIC16bootload/" TARGET="_blank">http://www.microchipc.com/PIC16bootload/</a>
They include the source code in the Zip file.

2. Don't put a jump in the first four words of ROM. Instead,
have your C program check for a RS-232 message that
invokes the bootloader function. I posted code for that:
<a href="http://www.pic-c.com/forum/general/posts/7604.html" TARGET="_blank">http://www.pic-c.com/forum/general/posts/7604.html</a>

But I suspect that you want to continue using your existing
method of doing a bootloader. What if you used self-modifying
code ? The first time your program runs, it could change the
value of the first four ROM words. It could use the
write_program_eeprom() function to change the code so that it
jumps to your bootloader function upon power-up.


___________________________
This message was ported from CCS's old forum
Original Post ID: 10472
Gary Smithson
Guest







Re: Relocation of code / CodeLoader
PostPosted: Mon Jan 06, 2003 6:52 pm     Reply with quote

:=Hi,
:=
:=I use a bootloader in my wireless control applications for firmware upgrade.
:=
:=The bootloader is run at power up by installing a jump at 0000H and then
:=return to 0003H after the bootloader is finished.
:=
:=The current code was compiled using Hi-Tech C and the main source was
:=relocated to start at 0003H using the following code...
:=
:=#asm
:= psect powerup, class=CODE, delta=2
:= global powerup, start
:=powerup:
:= org 0x3
:= goto start
:=#endasm
:=
:=Can someone here advise me how I can accomplish the same effect using CCS
:=compiler ?
:=
:=Thanks in advance
:=
:=Kind regards
:=
:=David Huisman

In my opinion the process can be much simpler than what you have had to do in the past. I have written a bootloader in CCS C (source code available free) that performs the function that you need. The trick is to let the bootloader worry about the reset vector so that you as the programmer don't have to relocate it. You just write your application code as if the bootloader was not there (even non-CCS applications). The bootloader captures the application reset vector and stores it elsewhere as an application is downloaded. On each reset when the bootloader decides that it is not being called on, it goes to the application entry point. Done. You can use my bootloader as is or just use the concept in your own. It can be found at <a href="http://www.thebytefactory.com" TARGET="_blank">http://www.thebytefactory.com</a> under the Download menu. If you need a version that does not require a hardware pin to trigger it, e-mail me. My address is on the Contact page.

Regards,
Gary S.
___________________________
This message was ported from CCS's old forum
Original Post ID: 10485
Ron
Guest







Re: Relocation of code
PostPosted: Wed Jan 08, 2003 4:15 am     Reply with quote

Relocating the reset vector in CSS can be done by including the following line:

#build(reset=0x100)

Best regards,
Ron



:=Hi,
:=
:=I use a bootloader in my wireless control applications for firmware upgrade.
:=
:=The bootloader is run at power up by installing a jump at 0000H and then
:=return to 0003H after the bootloader is finished.
:=
:=The current code was compiled using Hi-Tech C and the main source was
:=relocated to start at 0003H using the following code...
:=
:=#asm
:= psect powerup, class=CODE, delta=2
:= global powerup, start
:=powerup:
:= org 0x3
:= goto start
:=#endasm
:=
:=Can someone here advise me how I can accomplish the same effect using CCS
:=compiler ?
:=
:=Thanks in advance
:=
:=Kind regards
:=
:=David Huisman
___________________________
This message was ported from CCS's old forum
Original Post ID: 10532
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