|
|
View previous topic :: View next topic |
Author |
Message |
Chill
Joined: 01 Jun 2010 Posts: 10
|
Bootloader example code compile error |
Posted: Tue Jun 01, 2010 3:08 am |
|
|
Hi all,
I create a project simply with CCS example codes as below,
bootloader.h
ex_bootloader.c
loader.c
18F452.h
One error comes out:
"*** Error 128 "loader.c" Line 42(1,4): A #DEVICE required before this line"
Part of the code, shows where the error happens,
"
#define LOADER_ADDR LOADER_END-LOADER_SIZE
#define BUFFER_LEN_LOD 64
int buffidx;
char buffer[BUFFER_LEN_LOD];
#define ACKLOD 0x06
#define XON 0x11
#define XOFF 0x13
"
So why the compilation fail?
Actually i have no idea of the layout the bootloader example code.
And i want to put a bootloader code in the upper flash memory, but in trouble of using the "ORG"...
Thanks in advance. |
|
|
collink
Joined: 08 Jan 2010 Posts: 137 Location: Michigan
|
|
Posted: Tue Jun 01, 2010 5:47 am |
|
|
You need to tell the compiler information about which PIC chip you plan to use. You need a line like:
#include <18F2685.h>
Substitute the proper header for your chip. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Jun 01, 2010 5:52 am |
|
|
... and make this device include file the first line in your program. |
|
|
Chill
Joined: 01 Jun 2010 Posts: 10
|
|
Posted: Tue Jun 01, 2010 11:38 am |
|
|
Thanks ckielstra, collink,
Previous at the head of ex_bootloader.C, where the main located.
Code: |
if defined(__PCM__)
#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) // Jumpers: 8 to 11, 7 to 12
#elif defined(__PCH__)
#include <18F452.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) // Jumpers: 8 to 11, 7 to 12
#endif
|
I use a simple "#include <18F452.h>" to replace the above code.
The error " A #DEVICE required before this line" disappear.
Then include some related head files,
<stdio.h>, <stddef.h>, <string.h>,<ctype.h>.
I come with the error as below,
--------------------------------------------------------
Executing: "C:\Program Files\PICC\Ccsc.exe" +FH "ex_bootloader.c" +EXPORT +DF +LN +T +A +M +Z +Y=9 +EA
--- Info 300 "C:\Users\Chill\Desktop\BootloaderCCS\loader.c" Line 66(33,34): More info: Segment at 00000-004FE (0000 used) Priv
--- Info 300 "C:\Users\Chill\Desktop\BootloaderCCS\loader.c" Line 66(33,34): More info: Segment at 00500-07FFE (0000 used)
--- Info 300 "C:\Users\Chill\Desktop\BootloaderCCS\loader.c" Line 66(33,34): More info: Attempted to create: 0010A-004FE for #org
*** Error 126 "C:\Users\Chill\Desktop\BootloaderCCS\loader.c" Line 66(33,34): Invalid ORG range
C:\Users\Chill\Desktop\BootloaderCCS\ex_bootloader.o ===> 1 Errors, 0 Warnings.
----------------------------------------------------------
Note that I make this project with below CCS example source files:
bootloader.h, ex_bootloader.c , loader.c
Thanks,
Chill |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jun 01, 2010 1:23 pm |
|
|
Quote: |
I create a project simply with CCS example codes as below,
bootloader.h
ex_bootloader.c
loader.c
18F452.h
|
Are you using MPLAB ? If so, there should be only one file listed in the
Project Window under Source files. It should be the Ex_Bootloader.c file.
I made a new project in the c:\Program Files\Picc\Examples directory
using the MPLAB Project Wizard. I gave the project the name of
Ex_Bootloader. I set up the project to use the 18F452. Then I added
the Ex_Bootloader.c file to the project and compiled it by clicking the
"Build All" button in MPLAB. It compiled with no errors.
The key point is that you should not "add" to the project all the various
files in your list above. Only the Ex_Bootloader.c file should be "added"
to the MPLAB project. If you have other files in the Source Files list in
MPLAB, then remove them. |
|
|
Chill
Joined: 01 Jun 2010 Posts: 10
|
|
Posted: Wed Jun 02, 2010 10:15 am |
|
|
Hi PCM programmer ,
Yes, I am using the MPLAB V8.50. CCS PCH V4.049
I have fully followed your procedure.
The compile error this time is,
"*** Error 18 "ex_bootloader.c" Line 41(10,20): File can not be opened"
It shows that #include <18F452.h> can not be open...
Actually I am used to assembly language, not good at C at all.
BTW, I was confused with #org. I read your post as below, it does help. Thanks.
Quote: |
Posted: Sun Jan 22, 2006 12:07 am
--------------------------------------------------------------------------------
I made the following program, based on your description, and it
compiles without error with PCH vs. 3.241.
Code:
#include <18F452.H>
#fuses XT,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay (clock=4000000)
#build (reset = 0x0002)
#rom 0x0000 = {0x0000}
#org 0x7F00, 0x7FFF
void my_function(void)
{
char c;
c = 0x55;
}
//==================================
void main()
{
my_function();
while(1);
} |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jun 02, 2010 10:53 am |
|
|
Quote: | The compile error this time is,
"*** Error 18 "ex_bootloader.c" Line 41(10,20): File can not be opened"
It shows that #include <18F452.h> can not be open...
|
Is this your first project with CCS ? Have you ever successfully compiled
a program before ? Do you have the PCH compiler installed ? Are you
using MPLAB as the IDE for the CCS compiler ? Have you installed the
CCS "plugin" program for MPLAB ? |
|
|
Chill
Joined: 01 Jun 2010 Posts: 10
|
|
Posted: Thu Jun 03, 2010 2:34 am |
|
|
Hi PCM programmer,
Confirmed that my PCH compiler is not installed well. Thanks. |
|
|
|
|
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
|