View previous topic :: View next topic |
Author |
Message |
Cogitum
Joined: 22 Mar 2012 Posts: 70 Location: France (Paris)
|
18F4550 & 18F45K50 bootloader problem ? Compiler 5.078 |
Posted: Fri May 03, 2019 10:22 am |
|
|
Hello,
I am having some problems using 2 different PICs and a bootloader.
I have 2x different boards
1 X with 18F4550
1 x with 18F45K50
PROCESS :
I load the bootloader and unplug the programmer.
I plug the USB connection cable.
2 push buttons allow me to switch to BOOT mode (recognition state 0 for one and reset for the other).
I open serial monitor and I can read " BOOTLOADER READY"!
Then "file then download software".
The program downloaded is the blinking LED. LEDs FLASH!
Everything is perfect with the 18F4550.
I do the same thing with the bootloader adapted for the 18F45K50.
I open serial monitor and I can read " BOOTLOADER READY"!
The led program is also suitable for the 18F45K50.
unfortunately the LEDs do not blink ???
Any suggestions or advice are welcome.
Thanks in advance for your help.
Code: |
#include <18F45K50.h>
#include <usb_bootloader.h>
//#include <ex_usb_hid.c>
#use delay(crystal=16MHz)
//****************************************************************************
#fuses none
//****************************************************************************
//#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
#use delay(clock=48000000)
// #use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
void main(void) {
{
while(TRUE)
{
output_toggle(PIN_E0);//LED1
delay_ms(100);
output_toggle(PIN_E1);//LED2 RED
delay_ms(100);
}
}
} |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19587
|
|
Posted: Fri May 03, 2019 12:19 pm |
|
|
Post the fuses your bootloader uses, and the compiler version.
My guess is that on the 45K50, PBADEN is being set, so port B5..0 all
wake up set as analog inputs. |
|
|
Cogitum
Joined: 22 Mar 2012 Posts: 70 Location: France (Paris)
|
18F4550 & 18F45K50 bootloader problem ? Compiler 5.078 |
Posted: Fri May 03, 2019 1:32 pm |
|
|
HI Ttelmah,
Thank for your quick answer. Sorry Compiler version is on the subject line
V : 5.078 .
Code: |
#fuses WDT_SW //No Watch Dog Timer, enabled in Software
#fuses CCP2C1 //CCP2 input/output multiplexed with RC1
#fuses PUT //Power Up Timer
#fuses BROWNOUT_SW //Brownout controlled by configuration bit in special file register
#fuses BORV19 //Brownout reset at 1.9V
#fuses PBADEN //PORTB pins are configured as analog input channels on RESET
#fuses T3CKC0 //T3 Clock In is on C0
#fuses SDOB3 //SDO is on RB3
#fuses MCLR //Master Clear pin enabled
#fuses NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#fuses NOSTVREN //Stack full/underflow will not cause reset
#fuses NOPROTECT //Code not protected from reading
#fuses NOCPB //No Boot Block code protection
#fuses NOCPD //No EE protection
#fuses NOWRT //Program memory not write protected
#fuses WRTC //Configuration registers write protected
#fuses NOWRTB //Boot block not write protected
#fuses NOWRTD //Data EEPROM not write protected
#fuses NOEBTR //Memory not protected from table reads
#fuses NOEBTRB //Boot block not protected from table reads |
Best regards |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9269 Location: Greensville,Ontario
|
|
Posted: Fri May 03, 2019 3:31 pm |
|
|
from your post..
Quote: | #fuses PBADEN //PORTB pins are configured as analog input channels on RESET |
so as Mr. T said........
you'll have to add NO infront of PBADEN
then it might work...
Jay |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri May 03, 2019 4:20 pm |
|
|
I don't think that's going to be it. Reason:
PCH vs. 5.078 has init code inserted by the compiler that sets
all i/o ports to digital. Example:
Code: |
.................... void main()
0004: CLRF TBLPTRU
0006: BCF RCON.IPEN
0008: MOVLW 50
000A: MOVWF OSCCON
000C: CLRF OSCCON2
000E: CLRF OSCTUNE
0010: MOVLB F
0012: CLRF x5B // ANSELA = 0
0014: CLRF x5C // ANSELB = 0
0016: CLRF x5D // ANSELC = 0
0018: CLRF x5E // ANSELD = 0
001A: CLRF x5F // ANSELE = 0
001C: CLRF CM2CON1
001E: CLRF CM2CON0
0020: CLRF CM1CON0 |
Test program:
Code: | #include<18F45K50.h>
#fuses NOWDT, PBADEN
#use delay(internal=4M)
//=================================
void main()
{
while(TRUE);
} |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19587
|
|
Posted: Sat May 04, 2019 1:31 am |
|
|
I think if the fuse if actually set to PBADEN, the compiler boot code
won't set the ports to digital. That is the 'default', but not when you explicitly
set the port to analog.... |
|
|
Cogitum
Joined: 22 Mar 2012 Posts: 70 Location: France (Paris)
|
18F4550 & 18F45K50 bootloader problem ? COMPILER 5.078 |
Posted: Sat May 04, 2019 3:30 am |
|
|
Hello,
First of all I want to thank you all 3 for your help!
NOPBADEN does not change anything ... the LEDs do not blink.
SIOW display BOOTLOADER READY 18F45K50 !
After loading the software "BLINK LED" SIOW display nothing "
No more BOOTLOADER READY 18F45K50 display is black !
The same process with 18F4550 works.
Best regards |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19587
|
|
Posted: Sat May 04, 2019 7:42 am |
|
|
Show your clock configuration, and tell us what the clock source is.
How is the bootloader triggered?. Input pin?. What pin?.
How big is the bootloader?. (compile it an look at the lst file).
One thought going through my head is that the size being reserved by
'usb_bootloader.h', is not actually large enough for your bootloader.
in the K50. |
|
|
Cogitum
Joined: 22 Mar 2012 Posts: 70 Location: France (Paris)
|
|
Posted: Sat May 04, 2019 7:52 am |
|
|
HI Ttelmah,
You will find below the files I use:
Code: | ///////////////////////////////////////////////////////////////////////////
//// EX_USB_BOOTLOADER.C ////
//// ////
/////////////////////////////////////////////////////////////////////////
//// ////
//// ex_usb_common.h ////
//// ////
///////////////////////////////////////////////////////////////////////////
//// ////
//// USB_BOOTLOADER.H ////
//// //// |
+++++++++++++++++++++++++++
Code removed.
Reason: Forum rule #10:
10. Don't post the CCS example code or drivers,
or ask for such code and drivers.
http://www.ccsinfo.com/forum/viewtopic.php?t=26245
- Forum Moderator
+++++++++++++++++++++++++++ |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: 18F4550 & 18F45K50 bootloader problem ? Compiler 5. |
Posted: Sat May 04, 2019 7:57 am |
|
|
Cogitum wrote: |
#include <18F45K50.h>
#include <usb_bootloader.h>
//#include <ex_usb_hid.c>
#use delay(crystal=16MHz)
//******************************************************
#fuses none
//*********************************************************
//#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
#use delay(clock=48000000)
// #use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
void main(void) {
{
while(TRUE)
{
output_toggle(PIN_E0);//LED1
delay_ms(100);
output_toggle(PIN_E1);//LED2 RED
delay_ms(100);
}
}
} |
You have two #use delay() statements. Why ? Use only one.
Also, read this thread, where Ttelmah explains the #fuses must be the
same.
http://www.ccsinfo.com/forum/viewtopic.php?p=165610
Also, read about using: #fuses none
https://www.ccsinfo.com/forum/viewtopic.php?t=56155 |
|
|
Cogitum
Joined: 22 Mar 2012 Posts: 70 Location: France (Paris)
|
18F4550 & 18F45K50 bootloader problem ? COMPILER 5.078 |
Posted: Sat May 04, 2019 8:03 am |
|
|
Next to Ttelmah
About clock source is CRYSTAL 16 MHZ pins are RA6 & RA7.
Trigger pin is RB4
Cable detect : RD4
Size of bootloader :
CCS PCH C Compiler, Version 5.078, xxxxx 04-mai-19 15:53
Filename: D:\ex_usb_bootloader.lst
ROM used: 5514 bytes (17%)
Largest free fragment is 24512
RAM used: 399 (19%) at main() level
541 (26%) worst case
Stack used: 9 locations (8 in main + 1 for interrupts)
Stack size: 31
Best Regards |
|
|
Cogitum
Joined: 22 Mar 2012 Posts: 70 Location: France (Paris)
|
18F4550 & 18F45K50 bootloader problem ? COMPILER 5.078 |
Posted: Sun May 05, 2019 12:01 am |
|
|
HI PCM Programmer,
Thanks for your support.
About your remark concerning two #delay().
I'm agree with you but ... i make different test
delete one of them >> I can compile my program.
Either is equal.
If i delete both compiler generate one error because I'm using for the blink led
delay_ms(100) ... I have make another test >> deleted this line ;delay_ms
I can compile but the final problem is the same with bootloader.
Additional test : hardware link between 45K50 and external HYPERTERMINAL.
result >> alone (without bootloader =RUN)
Using bootloader only this message BOOTLOADER READY 18F45K50
same message with SIOW !
However when I try to download my LED Blink program i can read this
message : Lines transferred 1 Total Lines 12 !
The green bargraph is stopped !!
Another small windows indicate Error #229 Timeout while downloading
This problem is not easy to solve (with 18F4550 everything work fine).
Unfortunately i need to use 18F45K50.
Best Regards |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19587
|
|
Posted: Sun May 05, 2019 10:49 am |
|
|
Unfortunately, what you have posted would involve hours of time for us
to decode.
Post just your code.
The code you have modified to be the bootloader for this chip.
Use the code buttons, so it is readable.
Your code should be setting the defines it needs to work.
You should never need to modify the CCS files since they allow
you to disable stuff that doesn't apply using defines. So don't post
these, just the settings that are used. Remember these need to be done
before the files are included.
Now your approach seems instead to have been to modify the CCS files.
This has led to errors. For instance, it looks as if PIN_USB_SENSE is
actually set to PIN_B2, when this is compiled for the 1845K50, while
it has been changed for the 4550. Might well explain why there are
issues here.... |
|
|
Cogitum
Joined: 22 Mar 2012 Posts: 70 Location: France (Paris)
|
18F4550 & 18F45K50 bootloader problem ? SOLVED :grin: |
Posted: Sun May 05, 2019 11:35 am |
|
|
Thank you Ttelmah for your valuable advice that I have taken into account.
I made the hardware changes for the sense and for the push button.
MY 18F45K50 CARD WORKS PERFECTLY NOW.
VERY RESPECTFULLY
Cogitum |
|
|
|