Page 2 of 3

Re: Help with USB HID BootLoader for PIC24FJ

Posted: 29 Jul 2014 13:07
by alvaro
The project.

Re: Help with USB HID BootLoader for PIC24FJ

Posted: 29 Jul 2014 14:00
by Rotary_Ed
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.

Re: Help with USB HID BootLoader for PIC24FJ

Posted: 29 Jul 2014 15:40
by alvaro
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.

Re: Help with USB HID BootLoader for PIC24FJ

Posted: 29 Jul 2014 23:38
by Rotary_Ed
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"?

Re: Help with USB HID BootLoader for PIC24FJ

Posted: 30 Jul 2014 07:27
by alvaro
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

Re: Help with USB HID BootLoader for PIC24FJ

Posted: 31 Jul 2014 12:37
by alvaro
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.

Re: Help with USB HID BootLoader for PIC24FJ

Posted: 31 Jul 2014 16:12
by alvaro
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.

Re: Help with USB HID BootLoader for PIC24FJ

Posted: 31 Jul 2014 16:30
by Rotary_Ed
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!

Re: Help with USB HID BootLoader for PIC24FJ

Posted: 26 Aug 2014 13:53
by alvaro
My program uses interrupts time and USART interrupts. How do I redefine my program to work?

Re: Help with USB HID BootLoader for PIC24FJ

Posted: 01 Sep 2014 12:07
by alvaro
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.

Re: Help with USB HID BootLoader for PIC24FJ

Posted: 01 Sep 2014 12:47
by Rotary_Ed
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

Re: Help with USB HID BootLoader for PIC24FJ

Posted: 02 Sep 2014 10:56
by alvaro
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.

Re: Help with USB HID BootLoader for PIC24FJ

Posted: 02 Sep 2014 13:04
by Rotary_Ed
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

Re: Help with USB HID BootLoader for PIC24FJ

Posted: 03 Sep 2014 08:24
by filip
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.

Re: Help with USB HID BootLoader for PIC24FJ

Posted: 03 Sep 2014 13:58
by Rotary_Ed
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.