View previous topic :: View next topic |
Author |
Message |
magestik
Joined: 16 Oct 2008 Posts: 59
|
Bootloader USB |
Posted: Thu Apr 16, 2009 8:26 am |
|
|
Hi there,
I'm currently trying to put a bootloader into my 18F4550.
I am following this for schematics, and this for the bootloader.hex. The *.hex is here.
Yet, they say this :
"When you plug the PIC in to your computer via USB, not much will happen, but if you hold the bootload button and press the reset button, two of the LEDs should begin flashing, and the computer should detect it as a new USB device, and ask you for a driver; direct it to the MCHPFSUSB driver and all should be OK, and you will see it in device manager."
I tried and nothing happened.
So i tried a simple program to make sure my board is working (sending keystrokes), which worked.
I am new with bootloaders, am i missing something ? or is there a better tutorial ?
Thank you. |
|
|
PICoHolic
Joined: 04 Jan 2005 Posts: 224
|
|
|
Kova
Joined: 06 May 2007 Posts: 35
|
|
Posted: Fri Apr 17, 2009 12:43 am |
|
|
Sorry but it's necessary only to include the USB_BOOTLOADER.H file ?
Some example?
Bye |
|
|
PICoHolic
Joined: 04 Jan 2005 Posts: 224
|
|
Posted: Fri Apr 17, 2009 8:41 am |
|
|
Yes just like that. Follow the microchip link to get the bootloader source code and PC software.
Good Luck |
|
|
magestik
Joined: 16 Oct 2008 Posts: 59
|
|
Posted: Thu Apr 30, 2009 9:48 am |
|
|
It took time, but it worked, thank you for the link, wonderful . |
|
|
PICoHolic
Joined: 04 Jan 2005 Posts: 224
|
|
Posted: Thu Apr 30, 2009 9:58 am |
|
|
|
|
|
magestik
Joined: 16 Oct 2008 Posts: 59
|
|
Posted: Mon May 04, 2009 8:49 am |
|
|
Hello, me again.
I tried the exact same schematic and bootloader on a 18LF4550, this time, whether RB4 is grounded or not, my program seems to run, no bootloader.
My question is, does this bootloader apply to 18F4550 and 18LF4550 ?
Is it <#include 18F4550.h> for LF version ?
Thank you. |
|
|
PICoHolic
Joined: 04 Jan 2005 Posts: 224
|
|
Posted: Mon May 04, 2009 8:56 am |
|
|
It works on both. Actually on all USB PIC micros. |
|
|
magestik
Joined: 16 Oct 2008 Posts: 59
|
|
Posted: Mon May 04, 2009 9:02 am |
|
|
Well it doesn't for me .
My program is just blinking a led, and it keeps blinking, whether RB4 = 0 or 1. Actually, with RB4=0, the led should stop blinking because of the bootloader... it doesn't, which indicate me that the program is well in the pic, but the bootloader doesn't work. |
|
|
PICoHolic
Joined: 04 Jan 2005 Posts: 224
|
|
Posted: Mon May 04, 2009 11:46 am |
|
|
I've been using this bootloader for the 18FX7J50 series. It works perfect. You need to change the bootloader code to adapt it to your hardware i.e. change the USB sense pin, the bootloader detect pin, etc...
Recompile it (under C18) and include the .H file indicated above.
This should work.
Good Luck |
|
|
magestik
Joined: 16 Oct 2008 Posts: 59
|
|
Posted: Tue May 05, 2009 1:23 am |
|
|
PICoHolic wrote: | You need to change the bootloader code to adapt it to your hardware i.e. change the USB sense pin, the bootloader detect pin, etc... |
I thought i just had to include the header file above, for the 18F4550 i didn't change anything else. Everywhere on the internet i see RB4 for the bootloader pin, i didn't think i had to change this one, i don't even see where it is declared as the bootloader pin :(. |
|
|
PICoHolic
Joined: 04 Jan 2005 Posts: 224
|
|
Posted: Tue May 05, 2009 1:33 am |
|
|
The header file above just remaps the reset and interrupt vectors. You need to change few things in the bootloader firmware provided by Microchip as described above in order to adapt it to your hardware.
You may download a free version of C18 compiler student edition.
The changes are mainly in the "io_cfg.h" and in main() function.
Bootloader path: "C:\Microchip Solutions\USB Device - Bootloaders\HID - Bootloader\HID Bootloader - Firmware for PIC18 Non-J Devices"
Good Luck |
|
|
magestik
Joined: 16 Oct 2008 Posts: 59
|
|
Posted: Tue May 05, 2009 9:03 am |
|
|
Thanks for your help. I will have a look at those files.
But still :
- This code + usb_bootloader.h (same as above) works with a 18F4550, meaning i can run the program (led blinking + usb) or bootload.
- This same code + usb_bootloader.h does not work with a 18LF4550, only the led is blinking, no usb signal.
If i comment the use of usb_bootloader.h, the usb signal works. I really don't understand why .
Code: | #include <18F4550.h>
//#include "usb_bootloader.h"
#fuses HS,WDT,NOPROTECT,NOLVP,USBDIV,PLL5,CPUDIV1,VREGEN
#use delay(clock=20000000) // 48000000
//Tells the CCS PIC USB firmware to include HID handling code.
#define USB_HID_DEVICE TRUE
//the following defines needed for the CCS USB PIC driver to enable the TX endpoint 1
#define USB_EP1_TX_ENABLE USB_ENABLE_INTERRUPT //turn on EP1 for IN bulk/interrupt transfers
#define USB_EP1_TX_SIZE 8
#define USB_EP2_TX_ENABLE USB_ENABLE_INTERRUPT //turn on EP2 for IN bulk/interrupt transfers
#define USB_EP2_TX_SIZE 8
#define USB_EP2_RX_ENABLE USB_ENABLE_INTERRUPT //turn on EP2 for IN bulk/interrupt transfers
#define USB_EP2_RX_SIZE 4
#define LED1 PIN_D2
#include <pic18_usb.h>
#include <usb_desc_kbmouse.h> //USB Configuration and Device descriptors for this UBS device
#include <usb.c> //handles usb setup tokens and get descriptor reports
static int8 tx_msg[7]={0,0,0,0,0,0,0}; // 8 bytes array
int8 i=0;
void main(void)
{
int8 led_count;
usb_init_cs();
while(1)
{
RESTART_WDT();
usb_task();
led_count++;
if(led_count > 60)
{
led_count=0;
output_toggle(LED1);
}
if(usb_enumerated())
{
tx_msg[4] = 0x14;
usb_put_packet(2,tx_msg,sizeof(tx_msg),USB_DTS_TOGGLE);
tx_msg[4] = 0x00;
usb_put_packet(2,tx_msg,sizeof(tx_msg),USB_DTS_TOGGLE);
tx_msg[4] = 0x05;
usb_put_packet(2,tx_msg,sizeof(tx_msg),USB_DTS_TOGGLE);
tx_msg[4] = 0x00;
while(!(usb_enumerated()));
}
}
}
|
|
|
|
mskala
Joined: 06 Mar 2007 Posts: 100 Location: Massachusetts, USA
|
|
Posted: Tue May 05, 2009 2:55 pm |
|
|
I can't say I've followed the whole thread, but I use a similar USB bootloader on 18LF4550.
Are you leaving out any details? I ask that because there is no reason to switch from 18F4550 to 18LF4550, that part is more expensive for no additional features. You would go to it if you had to change to lower voltage. Keep in mind that 20MHz is not guaranteed to work at 3.3V. |
|
|
magestik
Joined: 16 Oct 2008 Posts: 59
|
|
Posted: Tue May 05, 2009 3:12 pm |
|
|
I didn't leave any detail, my schematic is the same as above, only running @3.3v with an additional voltage regulator.
There is a reason, the 18F4550 cannot operate @ 3.3v, which i need .
Could you post the bootloader you used for the 18LF4550 ?
Thanks. |
|
|
|