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

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



Joined: 27 Jul 2013
Posts: 79

View user's profile Send private message

Bootloader on PIC18F45K22
PostPosted: Fri Jun 27, 2014 10:14 am     Reply with quote

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: 9205
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Jun 27, 2014 10:31 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jun 27, 2014 10:37 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jun 27, 2014 11:12 am     Reply with quote

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: 19454

View user's profile Send private message

PostPosted: Fri Jun 27, 2014 11:31 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jun 27, 2014 11:42 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jun 27, 2014 3:31 pm     Reply with quote

I even tried with 18F45K22 that comes default with the example, no luck.
Help please.
temtronic



Joined: 01 Jul 2010
Posts: 9205
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Jun 27, 2014 7:37 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Jun 28, 2014 5:09 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Jun 28, 2014 9:31 am     Reply with quote

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: 9205
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Jun 28, 2014 9:55 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Jun 28, 2014 10:03 am     Reply with quote

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: 1932
Location: Norman, OK

View user's profile Send private message

PostPosted: Sat Jun 28, 2014 2:24 pm     Reply with quote

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: 19454

View user's profile Send private message

PostPosted: Sat Jun 28, 2014 2:28 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Jun 28, 2014 7:40 pm     Reply with quote

I was able to make the CCS bootloader work for the 18F45K22 in this
thread. Based on the date, I was probably using vs. 4.119. Note that
I don't let the compiler specify the important fuses. I put them in the
program. See the end of this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=44925

At the end of this next thread, Ttelmah explains how the Windows
Device Manager can affect SIOW handshaking:
http://www.ccsinfo.com/forum/viewtopic.php?t=50791
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 1, 2  Next
Page 1 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