View previous topic :: View next topic |
Author |
Message |
Boyko
Joined: 11 Oct 2004 Posts: 13 Location: Sofia
|
How to inform the compiler for a bootloader? |
Posted: Mon Oct 11, 2004 5:57 am |
|
|
Hi.
I'm a begginer with the CCS C.
Till now I used Pibasic pro and Proton+. When I want to tell the compiler that I'll load the HEX file into the PIC with a bootloader I only have to type:
Define loader_used 1 --> for PBP
Bootloader = 1 --> for Proton+
Now I have the CCS compiler, but I don't know what line I've to type to inform the compiler for the bootloader. My PIC is 18F452 and I intend to use the microcode loader.
Any help will be greatly appreciated. _________________ Regards
Boyko |
|
|
dvsoft
Joined: 28 Nov 2003 Posts: 46
|
|
Posted: Mon Oct 11, 2004 6:55 am |
|
|
bonjour
that depend of your bootloader
reserver is needed place in ROM for the code of the bootloader and to indicate the new location of the reset
Code: |
//---------------------------------------------------------------------------
// BootLoader
//
#build(reset=0x200, interrupt=0x208)
#org 0x0000,0x01FF // BootLoader Rom location
//---------------------------------------------------------------------------
void bootloader()
{
#asm
nop
#endasm
}
|
I use the following code with my bootloader |
|
|
Boyko
Joined: 11 Oct 2004 Posts: 13 Location: Sofia
|
|
Posted: Tue Oct 12, 2004 7:31 am |
|
|
Please help. I don't know what's wrong. I'm loading the HEX file with the Microcode loader, but the program doesn't work (i.e. the LED does not blink). Here it is the code:
Code: |
#include <18F452.h>
#use delay(clock=4000000)
#define led PIN_D0
//---------------------------------------------------------------
// BootLoader
//
#build(reset=0x200)
#build(interrupt=0x208)
#org 0x0000,0x01ff
//---------------------------------------------------------------
void bootloader()
{
#asm
nop
#endasm
}
main() {
while(1==1) {
output_low(led);
delay_ms(1000);
output_high(led);
delay_ms(1000);
}
}
|
What I have to do? _________________ Regards
Boyko |
|
|
Guest
|
|
Posted: Tue Oct 12, 2004 7:48 am |
|
|
you are missing all the fuses. When you you the wizard it sets them up for you. If you do it manually then you have to do it yourself
something like
Code: |
#fuses NOWDT, NOLVP, H4 ......,
|
do a search on #fuses |
|
|
Boyko
Joined: 11 Oct 2004 Posts: 13 Location: Sofia
|
|
Posted: Tue Oct 12, 2004 11:52 am |
|
|
Nope. This is not the problem. I've added the following line:
#fuses XT,NOPROTECT,NOLVP,NOWDT
but the led still does not blink.
May be the reset and interrupt vectors must be different? _________________ Regards
Boyko |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Oct 12, 2004 11:57 am |
|
|
You keep referring to a bootloader which you call a "microcode loader".
What company makes this bootloader ? Can you post a link to their
website. If we know more about the bootloader, then we can possibly
tell you how to make it work with CCS. |
|
|
Boyko
Joined: 11 Oct 2004 Posts: 13 Location: Sofia
|
|
Posted: Tue Oct 12, 2004 12:08 pm |
|
|
Microcode loader is a part from the Microcode studio, which is the IDE for Picbasic pro.
Here it is the link for the Microcode loader part:
http://www.mecanique.co.uk/code-studio/loader/index.html
I can send you the microcode loader if it helps. _________________ Regards
Boyko |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Oct 12, 2004 12:43 pm |
|
|
I read their page. This bootloader sounds very much like the
one from http://www.microchipc.com, because they mention
relocating the first 4 words of ROM.
In that case, the following code should work. You don't need to
use the #build directive.
When you initially program the "pre-compiled HEX file" into
your 18F452, make sure that you check the Config bit settings.
Make sure that it's set for XT, and that Watchdog and LVP are Disabled.
It also would help if Brownout and Power-up Timer are enabled.
The #fuse line shown in the application program below
actually won't be programmed into the PIC. The Config
bit settings used are the ones in the "pre-compiled HEX file"
(or the ones that you set in the PicStart-Plus Config Bits window).
Code: | #include <18F452.H>
#fuses XT, PUT, BROWNOUT, NOWDT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#define led PIN_D0
// Reserve the top 384 words (768 bytes) of ROM for the bootloader.
#org 0x7D00, 0x7FFF {}
//=================================
main()
{
while(1)
{
output_low(led);
delay_ms(500);
output_high(led);
delay_ms(500);
}
} |
|
|
|
|