|
|
View previous topic :: View next topic |
Author |
Message |
SeeCwriter
Joined: 18 Nov 2013 Posts: 160
|
Using Bootloader |
Posted: Mon Nov 23, 2015 4:32 pm |
|
|
I created a new project using the project wizard for an 18F67K22 and opted to use the bootloader. After the project was created, without making any changes to the code, I compiled the project and got reams of errors.
The first error is "Can not mix GLOBAL with non-global", and it is referring to this statement:
Code: |
#INT_GLOBAL
void isr(void){
jump_to_isr(LOADER_END+9);
}
|
What's up with that? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Mon Nov 23, 2015 6:30 pm |
|
|
Without seeing the rest of the program I can't say 100% that the line you said is the culprit. Often the compiler will go further so you _think_ it''s that line but really it's 3,4 or 10 lines before!
Post a SMALL, compilable program that shows the problem. Code snippets just don't show all !
Jay |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Nov 23, 2015 6:41 pm |
|
|
In addition to that, post your compiler version. Because I dropped your
snippet into a PCH template, added a quick #define for LOADER_END,
and it compiled with no errors with vs. 5.051. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Tue Nov 24, 2015 5:30 am |
|
|
I'd suspect he might be trying to use interrupts in the bootloader.
This is hard to do, if you want to use interrupts in the main code as well, and will slow the main code interrupt response significantly.
To do this, you have to add the code to int_global, to save the minimum registers, then test if you are in the bootloader, and if so, call the bootloader interrupt code (which will need to save the rest of the registers). It can't be called by the standard interrupt handling. If you are not in the bootloader, instead you perform the jump_to_isr.
If you look at the USB example, you will see that the bootloader _polls_ the USB interrupt. The serial example similarly does not use interrupts in the bootloader. It is complex, dangerous, and quite a lot of work.
Given the bootloader, is fundamentally a 'single task' program (just has to read the data and write it to the memory), in general it is much easier to never use interrupts inside the bootloader. |
|
|
davidd
Joined: 30 Sep 2010 Posts: 38
|
|
Posted: Mon Nov 30, 2015 3:12 am |
|
|
SeeCwriter,
Were you able to resolve this issue?
I am having the same error...
Thanks
Dave |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Mon Nov 30, 2015 3:56 am |
|
|
I'd refer to my earlier reply.
Key thing to understand, is that the bootloader uses INT_GLOBAL, and with this present you cannot have any standard interrupt handler in the bootloader.
So if your bootloader itself uses interrupts, you will get this problem.
You can be using interrupts without really realising it.
Remember that if (for example) you enable the serial buffering options in #USE RS232, this implicitly creates a #INT_RDA, if you specify a receive buffer. Do this and you will get this error.
So take the supplied bootloader example, and compile if for a PIC18, and it'll compile fine. However edit the #use RS232 to say:
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, RECEIVE_BUFFER=16)
and immediately you will have this error, since you are generating a #INT_RDA, which you cannot have at the same time as an #INT_GLOBAL..... |
|
|
SeeCwriter
Joined: 18 Nov 2013 Posts: 160
|
|
Posted: Tue Jan 12, 2016 3:28 pm |
|
|
I'm back on this project again. I think this particular problem is caused by the way I created the project.
The application I'm writing is a separate project/program from the bootloader program. When I created
the project in the Project Wizard, I created a single project to do both.
Once I stripped the bootloader code from my project, except for the #include to bootloader.h, it now
compiles without errors.
Next I created a bootloader project for my particular PIC (18F67K22), and it too compiles without errors.
But I noticed that the Project Wizard created a header file named "myprojBL.ccpjt_bootloader.h", which is
a really weird name. The header is not included in any of the source files that the wizard created, so I'm
not sure what I'm supposed to do with it. The entire contents of the file are the following:
Code: |
//bootloader code
#org LOADER_END+$001, LOADER_END+$002
void application(void) {
while(TRUE);
}
|
|
|
|
|
|
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
|