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

help with bootloader on 18f458

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



Joined: 26 Jan 2004
Posts: 15
Location: Kiruna, Sweden

View user's profile Send private message

help with bootloader on 18f458
PostPosted: Sun Apr 10, 2005 1:14 pm     Reply with quote

Hello all. I’m currently working on a small application where I would like to implement a bootloader. I guess it’s just me who has this “problem”, especially since I have not seen any clear answer to this in earlier posts on the subject.
The bootloader I have started to work with is the “Tinybootloader”, since it seems like a simple alternative and some here on the forum seems to have used it before.
The first question I have concerns the space reservation code that has to be included in the application program. As for the tinybootloader it has been very simply illustrated in assembler, for the 18f:
Code:
org 0
goto main

Seems simple enough, but where is this code suppose to be? Fist in the program, sure, but is it suppose to be right after the configuration section with fuses etc. or...?
Does anyone who is using the tinybootloader have like an example of code for this that I could try? My application is using following device:
18f458 @ 20Mhz
The application is suppose to use the uart with a baudrate of 28.8 kbps. Have there been problems with serial communication in application using bootloaders? If so, do you have any suggestions that could minimize the possibility of these problems?
Hope my problem is clear and not much of a problem for others.

Best wishes
/J.R
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Apr 10, 2005 2:28 pm     Reply with quote

Quote:
The first question I have concerns the space reservation code that has to be included in the application program. As for the tinybootloader it has been very simply illustrated in assembler, for the 18f:
Code:
org 0
goto main

Since you're using the 18F458, I assume you're using the CCS demo.
I downloaded the demo and compiled a few test programs with it.
I then looked at the .LST file and checked the code at adresses 0-4.
In each test, it had a GOTO there. Example:
Code:
#include <18F458.h>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, BORV42, PUT, NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

void main()
{
printf("Hello World\n\r");

while(1);
}


Here is part of the .LST file for the code above. Note that there
is a GOTO at address 0, and that it jumps to main() at 0022.
This meets the requirements of the bootloader.
Code:
CCS PCH C Compiler, Version 3.219d, xxxxx               10-Apr-05 13:18

               Filename: C:\Program Files\PCWH\Projects\Test.LST

*
0000:  GOTO   0022
....................  #include <18F458.h>
....................  //////// Standard Header file for the PIC18F458 device ////////////////
.................... #device PIC18F458
.................... #list
....................
.................... #fuses HS, NOWDT, NOPROTECT, BROWNOUT, BORV42, PUT, NOLVP
.................... #use delay(clock=20000000)
.................... #use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
....................
.................... void main()
.................... {
0022:  CLRF   FF8
0024:  BCF    FD0.7
0026:  CLRF   FEA
0028:  CLRF   FE9
002A:  BSF    FC1.0
Etc.

=========================
Now let's do a test with an isr in it. (#int_rda, in this case).
Code:
#include <18F458.h>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, BORV42, PUT, NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

#int_rda
void rda_isr()
{
char c;
c = getc();
}

void main()
{
printf("Hello World\n\r");

while(1);
}


Here is the .LST file. Again, notice that it has a GOTO at 0, and that
it jumps to main() at address 00E4.
Code:
CCS PCH C Compiler, Version 3.219d, xxxxx           10-Apr-05 13:23
           Filename: C:\Program Files\PCWH\Projects\Test.LST
*
0000:  GOTO   00E4
*
0008:  MOVWF  05
000A:  MOVFF  FD8,06
.....  (most interrupt dispatcher code deleted for brevity)
008E:  MOVF   05,W
0090:  MOVFF  06,FD8
0094:  RETFIE 0
....................  #include <18F458.h>
....................  /// Standard Header file for the PIC18F458 device /////
.................... #device PIC18F458
.................... #list
....................
.................... #fuses HS, NOWDT, NOPROTECT, BROWNOUT, BORV42, PUT, NOLVP
.................... #use delay(clock=20000000)
.................... #use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
00BE:  BTFSS  F9E.5
00C0:  BRA    00BE
00C2:  MOVFF  FAB,17
00C6:  MOVFF  FAE,01
00CA:  BTFSS  17.1
00CC:  BRA    00D2
00CE:  BCF    FAB.4
00D0:  BSF    FAB.4
00D2:  NOP
00D4:  GOTO   00DA (RETURN)
....................
.................... #int_rda
.................... void rda_isr()
.................... {
.................... char c;
.................... c = getc();
00D8:  BRA    00BE
00DA:  MOVFF  01,19
.................... }
....................
....................
00DE:  BCF    F9E.5
00E0:  GOTO   0054
.................... void main()
.................... {
00E4:  CLRF   FF8
00E6:  BCF    FD0.7
00E8:  BSF    0D.7
00EA:  CLRF   FEA
Etc.
Sandman



Joined: 26 Jan 2004
Posts: 15
Location: Kiruna, Sweden

View user's profile Send private message

PostPosted: Mon Apr 11, 2005 5:12 pm     Reply with quote

Well, I have some errors, (or unexpected differences between actual and expected settings) in the configuration bits, after have changed and hex-converted the .asm file for the bootloader in MPLAB. The application seemed to be working anyway thou. Then I discovered that it was only the first time. After the application software have been loaded ones the pic can no longer be programmed using the bootloader.
I must admit I didn’t really understand how the goto instruction in the beginning of the file CCS generated could be directly implemented for the bootloader. First I thought that it meant that space was already reserved that could be used by the loader. I thought it seemed a bit nuts, but I tested and the tried to load in the application software without adding any extra code for space reservation.
This might be the error since the tinybootloader can no longer detect the pic unless I reprogram the bootloader block using the ICD.
So apparently I have not fully understood your post. Sorry Rolling Eyes
Any other thoughts??
Stefan
Guest







PostPosted: Tue Apr 12, 2005 10:29 am     Reply with quote

#fuse in the main Program must be the same as in CCS bootloader

I had to include the correct bootloader.h in the main project
Sandman



Joined: 26 Jan 2004
Posts: 15
Location: Kiruna, Sweden

View user's profile Send private message

PostPosted: Tue Apr 12, 2005 12:18 pm     Reply with quote

Bootloader.h ? Is it included in one of the later versions of the compiler? I have version 3.174 (rather old), and it has only a loader.c and ex_load.c. Have anyone used these, or versions of these for bootloading applications?
Sandman



Joined: 26 Jan 2004
Posts: 15
Location: Kiruna, Sweden

View user's profile Send private message

PostPosted: Thu Apr 14, 2005 3:21 am     Reply with quote

Ok, I don’t know what happened, but now the TinyBootloader works fine. Laughing
Without problems, but no changes have been made. Well, [censored] behind the wheel as usual I guess, Rolling Eyes but now I got something to work with.

Over and out
/J"S"R
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