View previous topic :: View next topic |
Author |
Message |
haxan7
Joined: 27 Jul 2013 Posts: 79
|
Bootloader on PIC18F45K22 |
Posted: Fri Jun 27, 2014 10:14 am |
|
|
I am following CCS Bootloader example, but i can't seem to successfully upload my test program.
Code is essentially the same as in the example, so I am not sure if i should quote the code.
Uploads stops at line 1 with Siow with timeout error.
With teraterm (with right settings) program uploads and the test program does not run.
Compiler Version: 5.008
PIC: 18F46K22
Last edited by haxan7 on Sun Jun 29, 2014 12:49 pm; edited 1 time in total |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9220 Location: Greensville,Ontario
|
|
Posted: Fri Jun 27, 2014 10:31 am |
|
|
ok... WITHOUT using the bootloader, can you program the PIC with the 'test program' or at least a '1Hz LED' program and have it work ??
hth
jay |
|
|
haxan7
Joined: 27 Jul 2013 Posts: 79
|
|
Posted: Fri Jun 27, 2014 10:37 am |
|
|
temtronic wrote: | ok... WITHOUT using the bootloader, can you program the PIC with the 'test program' or at least a '1Hz LED' program and have it work ??
hth
jay |
I burned the example bootload program (that i was using as test program with slight modifications) without bootloader, it works. |
|
|
haxan7
Joined: 27 Jul 2013 Posts: 79
|
|
Posted: Fri Jun 27, 2014 11:12 am |
|
|
I have attached the code below.
Bootloader
Code: |
#include <18F46K22.h>
#fuses NOWDT
#use delay(internal=16MHz)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#define PUSH_BUTTON PIN_B0
#define _bootloader
#include <bootloader.h>
#include <loader.c>
#org LOADER_END+2,LOADER_END+4
void application(void) {
while(TRUE);
}
void main(void) {
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();
}
application();
}
#int_global
void isr(void) {
jump_to_isr(LOADER_END+5*(getenv("BITS_PER_INSTRUCTION")/8));
}
|
Program
Code: |
#include <18F46K22.h>
#fuses NOWDT
#use delay(internal=16MHz)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#include <bootloader.h>
void main(void)
{
output_high(PIN_C0);
int8 i;
delay_ms(100);
printf("\r\nApplication Version 1.0\r\n");
while(TRUE)
printf("%u ",++i);
}
|
Last edited by haxan7 on Fri Jun 27, 2014 11:43 am; edited 1 time in total |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19494
|
|
Posted: Fri Jun 27, 2014 11:31 am |
|
|
The _program_ does not want to include 'loader.c'.
Look at ex_bootload.c
Note how it includes bootloader.h (which sets things up so that it loads as a program to be loaded with a bootloader), but does not include loader.c |
|
|
haxan7
Joined: 27 Jul 2013 Posts: 79
|
|
Posted: Fri Jun 27, 2014 11:42 am |
|
|
Ttelmah wrote: | The _program_ does not want to include 'loader.c'.
Look at ex_bootload.c
Note how it includes bootloader.h (which sets things up so that it loads as a program to be loaded with a bootloader), but does not include loader.c |
Removed It. Issue still unresolved.
Why does tera term successfully send the file, if SIOW doesn't? |
|
|
haxan7
Joined: 27 Jul 2013 Posts: 79
|
|
Posted: Fri Jun 27, 2014 3:31 pm |
|
|
I even tried with 18F45K22 that comes default with the example, no luck.
Help please. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9220 Location: Greensville,Ontario
|
|
Posted: Fri Jun 27, 2014 7:37 pm |
|
|
hmmm..back to basics...
My version of the bootloader is ONLY valid for 16F877 or 18F452 so I can't see a default using the 18F45K22.
As a general comment though ,CCS does not publish nonworking code. Providing you use the PICs they did, wire up the PIC as they did, it will work. You may have misread some of the comments they have in the code?
I do know the memory maps of PICs are vastly different but without seeing the bootloader code, I can't comment further. Please don't post the code though as that violates one of rules of the forum.
Perhaps others with your bootloader version will respond.
hth
jay |
|
|
haxan7
Joined: 27 Jul 2013 Posts: 79
|
|
Posted: Sat Jun 28, 2014 5:09 am |
|
|
temtronic wrote: | hmmm..back to basics...
My version of the bootloader is ONLY valid for 16F877 or 18F452 so I can't see a default using the 18F45K22.
As a general comment though ,CCS does not publish nonworking code. Providing you use the PICs they did, wire up the PIC as they did, it will work. You may have misread some of the comments they have in the code?
I do know the memory maps of PICs are vastly different but without seeing the bootloader code, I can't comment further. Please don't post the code though as that violates one of rules of the forum.
Perhaps others with your bootloader version will respond.
hth
jay |
I am pretty sure i did not miss anything, I copied the entire example the only change i made was changing the crystal value. |
|
|
haxan7
Joined: 27 Jul 2013 Posts: 79
|
|
Posted: Sat Jun 28, 2014 9:31 am |
|
|
I spied on the serial com, here is what I noticed.
PIC only replies of ACK randomly throughout the transmission, no XOFF or XON.
Any reason why this might be happening? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9220 Location: Greensville,Ontario
|
|
Posted: Sat Jun 28, 2014 9:55 am |
|
|
What is your hardware configuration ?
PC----???----PIC
RS232 ?
USB modules?
Does the PIC run the 1Hz LED program 100%.
WHAT mods to the CCS programs did you make?
hth
jay |
|
|
haxan7
Joined: 27 Jul 2013 Posts: 79
|
|
Posted: Sat Jun 28, 2014 10:03 am |
|
|
temtronic wrote: | What is your hardware configuration ?
PC----???----PIC
|
Laptop, PIC18F46K22, EasyPic v7
Quote: |
RS232 ?
USB modules?
|
I am using easypic v7, it has a FTDI (USB to ttl) that i am using.
Quote: |
Does the PIC run the 1Hz LED program 100%.
|
Yes.
Quote: |
WHAT mods to the CCS programs did you make?
|
The example in CCS v5 was for PIC18F45K22, I used the exact same code, the only change I made was changing the crystal to internal oscillator.
I know the oscillator is correctly selected because the bootloader prints correctly to the screen. |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
|
Posted: Sat Jun 28, 2014 2:24 pm |
|
|
I am not using the USB. I am using rs232 direct connect _________________ Google and Forum Search are some of your best tools!!!! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19494
|
|
Posted: Sat Jun 28, 2014 2:28 pm |
|
|
I'd step back, and do a really long serial test.
Have a program that reads perhaps 100 characters stores them, and then echoes these back to the PC.
Then on the PC, use the option to send a file, and send a file with 100 characters. Store the reply, and compare.
I have a nasty/sneaky suspicion you are running into a clock difference with the internal oscillator. Just enough to cause some characters to be received incorrectly. Result no ACK.
The internal oscillator should _just_ be good enough for reliable RS232, but if (for instance) the internal calibration has been lost, or you happen to have got a bad example, it'd explain the problems. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
|