Help with USB HID BootLoader for PIC24FJ

General discussion on mikroElektronika website & forums.
Author
Message
alvaro
Posts: 41
Joined: 20 Mar 2013 11:40

Re: Help with USB HID BootLoader for PIC24FJ

#16 Post by alvaro » 29 Jul 2014 13:07

The project.
Attachments
PIC24FJ.rar
(310.31 KiB) Downloaded 252 times

Rotary_Ed
Posts: 756
Joined: 26 Dec 2004 23:10
Location: Matthews, NC, USA
Contact:

Re: Help with USB HID BootLoader for PIC24FJ

#17 Post by Rotary_Ed » 29 Jul 2014 14:00

I'm afraid I know little to nothing about the PIC24. But, with the PIC32 I use - it has an OTG type USB.

I found that to get the bootloader to work that whatever configuration (including frequency) I was using for the program, I had to use the same exact configuration and then recompile the bootloader code with that configuration. Just recompiling it or using it as it comes did not work for me. I had to compile it with the same scheme .cfg for both.

Since the PIC32 had an OTG USB module, I also decided I had to provide the 5 volts required of any USB Host. So I used a small chip to monitor the Identification pin on the chip which determined based on the type of micro a/b USB plug whether the chip should act as a host or device. This switch would turn on 5 volts to the USB socket in order to act as a host or turn it off when acting as a device.

Now I have no clue whether any of this applies to your PIC24 or is helpful or not, but that is what I did.
Rotary_Ed
Matthews, NC USA
Rv-6A N494BW Rotary Powered

alvaro
Posts: 41
Joined: 20 Mar 2013 11:40

Re: Help with USB HID BootLoader for PIC24FJ

#18 Post by alvaro » 29 Jul 2014 15:40

Hi Rotary_Ed,

my problem is in the begining. The USB HID Bootloader from MikroE and the PC not detect the PCB with PIC24. I've wired directly the D-, D+ and ground to skip connector USB. Compile the example from MikroC dsPic and PIC24 and not work.
Thanks.

Rotary_Ed
Posts: 756
Joined: 26 Dec 2004 23:10
Location: Matthews, NC, USA
Contact:

Re: Help with USB HID BootLoader for PIC24FJ

#19 Post by Rotary_Ed » 29 Jul 2014 23:38

Unfortunately, I'm pretty much a novice with USB. I did find that (in my case) that I could not have the PC host with the USB-HID power my board, but had to have power to the chip from its own power supply. Also compiling the bootloader was not enough, in my case, I had to compile it with the same configuration as I did the chip I was programming.

Are you certain that you do not have to set/clear some pin such as an USB-ID pin to inform the chip on your board what role it should be - either host or in you case "Device"?
Rotary_Ed
Matthews, NC USA
Rv-6A N494BW Rotary Powered

alvaro
Posts: 41
Joined: 20 Mar 2013 11:40

Re: Help with USB HID BootLoader for PIC24FJ

#20 Post by alvaro » 30 Jul 2014 07:27

Hi, when I tried to Mikromedia all was well. When my design, do not know what fails. My only intention is for the PC to detect what is connected to the USB and using the program to load the firmware to do so. I tried to load the firmware that comes with it is PIC24FJ256GB110 Mikromedia and neither works. No longer a matter of if Hard or Soft. regards

alvaro
Posts: 41
Joined: 20 Mar 2013 11:40

Re: Help with USB HID BootLoader for PIC24FJ

#21 Post by alvaro » 31 Jul 2014 12:37

Hi, please, need help.
the only that not work in my project is the USB part and I not Know that to do. I'm desperated with this.
The project with VisualTFT works fine but the bootloader not works.
Can anyone give me configuration options or hardware settings?

PLEASE, HELP.

alvaro
Posts: 41
Joined: 20 Mar 2013 11:40

Re: Help with USB HID BootLoader for PIC24FJ

#22 Post by alvaro » 31 Jul 2014 16:12

Hi,
USB Bootloader works finaly.
I added this at main:

Code: Select all

 U1CON.PPBRST = 0;
 U1IE = 0;
 U1EIE = 0;
 U1IR = 0xFF;
 U1EIR = 0xFF;
 U1CON.USBEN= 1;
 U1OTGCON.OTGEN = 1;
 U1EP0.EPRXEN = 1;
 U1EP0.EPHSHK = 1;
 U1PWRC.USBPWR = 1;
 U1OTGCON.DPPULUP = 1;

Now, the application loaded trough Usb loader not works fine. It's necesary adjust the address of interrputs?
Thanks.

Rotary_Ed
Posts: 756
Joined: 26 Dec 2004 23:10
Location: Matthews, NC, USA
Contact:

Re: Help with USB HID BootLoader for PIC24FJ

#23 Post by Rotary_Ed » 31 Jul 2014 16:30

Great to hear you got it working.

Yes, I struggled until I also set

U1OTGCON.OTGEN = 1;

There are so many bits to set/clear in so many registers in these chips, its amazing we ever get them to work properly :D

That was the one thing that took me a while to discover. But, it was worth it, the USB HID loads my 500K of code in 8 seconds :shock: , it used to take 10 minutes to load 125K of code over the UART Rs232 link. So a major improvement in speed, in fact I now use the USB HID for my normal programming and only use the programmer to load the bootloader code.


Now onward!
Rotary_Ed
Matthews, NC USA
Rv-6A N494BW Rotary Powered

alvaro
Posts: 41
Joined: 20 Mar 2013 11:40

Re: Help with USB HID BootLoader for PIC24FJ

#24 Post by alvaro » 26 Aug 2014 13:53

My program uses interrupts time and USART interrupts. How do I redefine my program to work?

alvaro
Posts: 41
Joined: 20 Mar 2013 11:40

Re: Help with USB HID BootLoader for PIC24FJ

#25 Post by alvaro » 01 Sep 2014 12:07

Hi to all,
pls, I need help to remapping the 3 interrupts in my project to use with USB bootloader.
the interrupts are:

Code: Select all

void Timer4Interrupt() iv IVT_ADDR_T4INTERRUPT
void Timer5Interrupt() iv IVT_ADDR_T5INTERRUPT
void UART1RXInterrupt() iv IVT_ADDR_U1RXINTERRUPT
I don't know assign the new addresses to works fine.

Thanks in advance.

Rotary_Ed
Posts: 756
Joined: 26 Dec 2004 23:10
Location: Matthews, NC, USA
Contact:

Re: Help with USB HID BootLoader for PIC24FJ

#26 Post by Rotary_Ed » 01 Sep 2014 12:47

I don't know if you compiler has it, but check under the tools menu and see if the menu has an "Interrupt Assistant" and try it - it will give you the basic structure for any interrupt. If no "Interrupt Assistant" then the data sheet is the only recourse I know.

Good luck
Rotary_Ed
Matthews, NC USA
Rv-6A N494BW Rotary Powered

alvaro
Posts: 41
Joined: 20 Mar 2013 11:40

Re: Help with USB HID BootLoader for PIC24FJ

#27 Post by alvaro » 02 Sep 2014 10:56

Thanks Rotary_Ed.
In my project the interrupts work fine. The problem is when I load the project trought USB Bootloader. The interrupts not work. I think I may to remap this routines or remap the EBASE adress but I donn't know how to. In the project properties form I see nothing. Please, anybody can help me?
Regards.

Rotary_Ed
Posts: 756
Joined: 26 Dec 2004 23:10
Location: Matthews, NC, USA
Contact:

Re: Help with USB HID BootLoader for PIC24FJ

#28 Post by Rotary_Ed » 02 Sep 2014 13:04

Ah! I ran into the same problem. At least in my case, I found that the configuration of the bootloader code when you compile it MUST be identical to your project code configuration.

I could bootload with the USB-HID bootload and the chip would run but no interrupts would work. I then examined the configuration registers using the Project Edit function and noticed that some of the parameters were different. Your frequency ( divide and multiply by factor for the PPL circuit) must be identical with your projects, the other parameters shown on the project edit window should also be the same as your project configuration.

Then recompile the bootloader with the same configuration as your project code, load the newly compiled bootload code to your project chip, then use the USB-HID bootloader to load your project code.

At Least, that is what I found I had to do to get it to work with a PIC32MX chip and my Pascal compiler

Good Luck
Rotary_Ed
Matthews, NC USA
Rv-6A N494BW Rotary Powered

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Help with USB HID BootLoader for PIC24FJ

#29 Post by filip » 03 Sep 2014 08:24

Hi,
Ah! I ran into the same problem. At least in my case, I found that the configuration of the bootloader code when you compile it MUST be identical to your project code configuration.
Yes, the config bits should be the same as the one of the bootloader.

Regards,
Filip.

Rotary_Ed
Posts: 756
Joined: 26 Dec 2004 23:10
Location: Matthews, NC, USA
Contact:

Re: Help with USB HID BootLoader for PIC24FJ

#30 Post by Rotary_Ed » 03 Sep 2014 13:58

Hi Filip,

Thanks for the confirmation. I guess if you think about it, its obvious in hindsight, but at the time I didn't even think about the bootloaders configuration as I assumed the project code configuration would be the dominate configuration. I do not recall any mention of that need in the bootloader comments - but, as I said I guess to many/most it would have been obvious.

I have been using MK products for over a decade now - its been a great ride.
Rotary_Ed
Matthews, NC USA
Rv-6A N494BW Rotary Powered

Post Reply

Return to “Website & Forums General Discussion”