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 CCS Technical Support

Bootloader on PIC18F45K22
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
CYembedded



Joined: 31 Jan 2015
Posts: 6

View user's profile Send private message

PostPosted: Mon Feb 02, 2015 4:27 am     Reply with quote

Thanks for your reply.
I corrected the wrong lines and at last I got this error in my bootloader:

OUT of ROM, A segment or the program is too large application
Seg 00500-00502, 0004 left, need 00012

Bootloader program :
Code:

#include <main.h>
#fuses NOWDT,NOPROTECT,NOPLLEN
#use delay(internal=16MHz)
#use rs232(baud=9600, xmit=PIN_D6, rcv=PIN_D7, ERRORS)
#define PUSH_BUTTON PIN_A1

#define _bootloader

#include <bootloader.h>
#include <loader.c>

#if defined(__PCM__)
 #org LOADER_END+1,LOADER_END+2
#elif defined(__PCH__)
 #org LOADER_END+2,LOADER_END+4
#endif

void application(void)
{
   output_high(pin_b5);
   printf("\r\napplication...");
  while(TRUE);
}

void main()
{
   output_high(pin_b5);
   if(!input(PUSH_BUTTON))
   {
      printf("\r\nBootloader Version 1.0\r\n");
   
      // Let the user know it is ready to accept a download
      printf("\r\nWaiting for download...");
      load_program();
      printf("\r\n!!!");
   }

   application();
}

Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Mon Feb 02, 2015 5:25 am     Reply with quote

You are missing the point fractionally.

You have the dummy application, actually containing code in the bootloader.

It _musn't_.

It is just a dummy to be there as a 'placeholder'.

Because you have code in it, it won't fit in the space allocated for it.

Look at the 'application' as I post it. Look at your's.....
CYembedded



Joined: 31 Jan 2015
Posts: 6

View user's profile Send private message

PostPosted: Tue Feb 03, 2015 3:57 am     Reply with quote

Thanks for your interest.
The application worked fine. In gpio and sending string from the serial there is no problem.
The only problem I have just noticed that interrupts are not working.
When I loaded the program by Pickit2 without a bootloader it works fine.

When I loaded the program with a bootloader, I can control the gpios and serial port etc. but Interrupts (int_rda and int_rda2) are not working.

Is the problem with bootloader ?
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Tue Feb 03, 2015 4:11 am     Reply with quote

That's because you have left the interrupt re-vector stub out of your bootloader.....

Again look at the example. Note this bit:
Code:

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


This is the re-vector stub, that handles transferring interrupt traffic up to programs compiled to load with the bootloader. It's perfectly OK to leave it out if you are not using interrupts in the main code, but it is essential for these to work. Hence I didn't worry about it being missing.

If you have removed it because you are using interrupts in your bootloader, then you need to handle these correctly (it is possible), but you have to have this stub, and then inside it add a test to see if you are in the bootloader or in the main code. If in main code handle the re-vectoring, otherwise then test yourself for the interrupt required, and call the required routines.

Generally it is quicker for the main code, and less bulky, to not use interrupts in the bootloader.
CYembedded



Joined: 31 Jan 2015
Posts: 6

View user's profile Send private message

PostPosted: Tue Feb 10, 2015 3:42 am     Reply with quote

Hi Ttelmah,
I worked my bootloader successfully at last.
Now I wonder whether I can program my PIC by an external eeprom or flash memory IC. In order to do that I hope I should change the codes in loader.c with read_eeprom() functions instead of getc() or etc. ? Is it true?
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Tue Feb 10, 2015 9:06 am     Reply with quote

No. You'd need 'read_external_eeprom'. Read_eeprom is for the internal EEPROM. Do a search on the forum, this has been discussed in the past.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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