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

need help about bootload

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



Joined: 19 Aug 2008
Posts: 6

View user's profile Send private message

need help about bootload
PostPosted: Mon Aug 25, 2008 9:34 am     Reply with quote

Because my program need bootload function, NOW i am try to learn how to realize it.
I have searched something about bootload in this forum, and make a simplest bootload project using ex_bootloader.c, bootloader.c, bootloader.h and 18F452.h in CCS folder (just use example file and don't change, then i try to build, but CCS C complier always shows as below:
Executing: "C:\Program Files\PICC\Ccsc.exe" +FH "loader.c" +EXPORT +DF +LN +T +A +M +Z +Y=9 +EA
*** Error 128 "loader.c" Line 42(1,4): A #DEVICE required before this line
D:\bootload_1\loader.o ===> 1 Errors, 0 Warnings.
Halting build on first failure as requested.
BUILD FAILED: Fri Aug 29 14:56:37 2008

I am using MPlab V8.1 and ccs_pcwh_4.049, I don't know why. Thanks.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Aug 25, 2008 12:57 pm     Reply with quote

You don't need help on a bootloader, you need help on "A #DEVICE required before this line".

See this thread. Look near the end.
http://www.ccsinfo.com/forum/viewtopic.php?t=35724
joe2008



Joined: 19 Aug 2008
Posts: 6

View user's profile Send private message

PostPosted: Tue Aug 26, 2008 7:14 pm     Reply with quote

very thanks.
Now the simplest bootload project i make using ex_bootloader.c, bootloader.c, bootloader.h and 18F452.h in CCS folder can be build successful.
But i am still has some question about the example file in ccs folder.

1) what's use of below part in bootload.h since we defined _bootloader in ex_bootloader.c?
#ifndef _bootloader

#if defined(__PCM__)
#build(reset=LOADER_END+1, interrupt=LOADER_END+5)
#elif defined(__PCH__)
#build(reset=LOADER_END+1, interrupt=LOADER_END+9)
#endif

#org 0, LOADER_END {}

#endif

2)i add my own header file-PSMI_Definitions.h. It just define some static variables for my application program, no add anything else, but if define more variable, the CCS complier will show:
** Error 71 "ex_bootloader.c" Line 91(0,1): Out of ROM, A segment or the program is too large main
Seg 00040-0007E, 0040 left, need 0366
Seg 00080-000FE, 0080 left, need 0366
Seg 00100-00108, 0006 left, need 0366
Seg 0010A-004FE, 03F4 left, need 0366
Seg 00500-07FFE, 7AFC left, need 0366
Seg 00000-00006, 0004 left, need 0366
Seg 00008-0001C, 0000 left, need 0366
Seg 0001E-0003E, 0022 left, need 0366

1 Errors, 188 Warnings.
Halting build on first failure as requested.
BUILD FAILED: Tue Aug 26 12:11:19 2008


ex_bootloader.C
#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
#define APPLICATION_END (getenv("PROGRAM_MEMORY")-1)
#define _bootloader
#include <bootloader.h>
#include <loader.c>
#include <PSMI_Definitions.h>
#if defined(__PCM__)
#org LOADER_END+1,LOADER_END+10
#elif defined(__PCH__)
#org LOADER_END+2,APPLICATION_END
#endif
void application(void) {
while(TRUE);
}

#if defined(__PCH__)
#org 0x40,0x7F
#else
#org 0x20,0x3F
#endif
void main(void) {
if(!input(PIN_B5))
{
load_program();
}

application();
}

#ORG default

#int_global
void isr(void) {
jump_to_isr(LOADER_END+5*(getenv("BITS_PER_INSTRUCTION")/8));
}


psmi_definitions.h:
#ifndef _DEFINITIONS_H
#define _DEFINITIONS_H
#use i2c(Slave,Fast,sda=PIN_C4,scl=PIN_C3,RESTART_WDT,force_hw,address=0x20)
#use fast_io(A)
#use fast_io(B)
#use fast_io(C)
#use fast_io(D)
#use fast_io(E)

#byte PORTA = 0xF80
#byte PORTB = 0xF81
#byte PORTC = 0xF82
#byte PORTD = 0xF83
#byte PORTE = 0xF84
#byte REG_I2C_BUFFER = 0xFC9//SSP1BUF
#byte SSPCON = 0xFC6
#byte TRISA = 0xF92
#byte TRISB = 0xF93
#byte TRISC = 0xF94
#byte TRISD = 0xF95
#byte TRISE = 0xF96
#byte SSPCON2 = 0xFC5
#byte PR2 = 0xFCB
#byte SSPADD = 0xFC8
#byte SSPSTAT = 0xFC7
#byte REG_I2C_STATUS = 0xFC7

#bit TRISC_PWM = TRISC.2
#bit TRISC_SCL = TRISC.3
#bit TRISC_SDA = TRISC.4
//#bit TRISD_SCL_ADM = TRISD.1
//#bit TRISD_SDA_ADM = TRISD.2
#bit TRISD_SCL_ADM = TRISD.0
#bit TRISD_SDA_ADM = TRISD.1
#bit SSPCON_CKP = SSPCON.4
#bit SSPCON_SSPEN = SSPCON.5
#bit SSPCON_SSPOV = SSPCON.6
#bit SSPCON_WCOL = SSPCON.7
#bit SSPADD_A0 = SSPADD.1
#bit SSPADD_A1 = SSPADD.2

#bit SSPSTAT_BF = SSPSTAT.0

#case //case sensitive program coding setup

#define INI_PORTA 0b00000000
//#define INI_PORTB 0b00000100
#define INI_PORTB 0b00000000
#define INI_PORTC 0b00000100
//#define INI_PORTD 0b10000001
#define INI_PORTD 0b00000000
#define INI_PORTE 0b00000000

#define TRIS_PORTA 0b00101111
#define TRIS_PORTB 0b00111111
#define TRIS_PORTC 0b11011011
#define TRIS_PORTD 0b00100111
#define TRIS_PORTE 0b00000111

//==============================================
// DEFINITION OF CONSTANTS
//Threshold Levels for ADC

// integer 1024 where: integer = SW equivalent
// -------- = ------ Vmicro = input voltage to microcontroller analog pin
// Vmicro 2.5V

//Temperature Thresholds--------------------------------------------------------


static int1 i13V3SB_ON;
static int1 i13V3SB_0CPSTART;
static int1 i12Vstartup;
static int1 i12VUVP_PMBUSET;
static int1 i1flag_OCP1;
static int1 i1flag_OCW1;
static int8 i1flag_OCPdelay;

static int1 i1pin_FAN_FAIL_OUT;

#endif
I don't know the CCS complier how to deal with my header file.

if remove one line, such as "static int1 i1pin_FAN_FAIL_OUT;", can be build ok.

It seem the content of header file ocupy some wrong place of ROM,how to aviod it?Thanks.
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