PIC24 USB Host Mode

General discussion on mikroC PRO for dsPIC30/33 and PIC24.
Post Reply
Author
Message
pic32user
Posts: 23
Joined: 23 Apr 2013 13:58

PIC24 USB Host Mode

#1 Post by pic32user » 07 May 2019 16:10

Hi I'm looking for some example code for the PIC24 or PIC32 for USB Host mode??
Any help would be greatly appreciated. Thanks

User avatar
jovana.medakovic
mikroElektronika team
Posts: 986
Joined: 18 Dec 2018 10:36

Re: PIC24 USB Host Mode

#2 Post by jovana.medakovic » 08 May 2019 10:46

Hello,

On our LibStock, you can find an example for USB Host for PIC24 and PIC32:
https://libstock.mikroe.com/projects/vi ... st-library

Kind regards,
Jovana

pic32user
Posts: 23
Joined: 23 Apr 2013 13:58

Re: PIC24 USB Host Mode

#3 Post by pic32user » 08 May 2019 14:10

I looked at those examples and they don't do what I need. I have a HID Terminal device that I want to send commands too and read what is coming back. 1st I need to recognize the device.

User avatar
jovana.medakovic
mikroElektronika team
Posts: 986
Joined: 18 Dec 2018 10:36

Re: PIC24 USB Host Mode

#4 Post by jovana.medakovic » 08 May 2019 15:51

Hello,

In our compiler, you can find an example for HID terminal, so you can use both examples (USB Host and HID) to write your project.
For PIC32:
\Mikroelektronika\mikroC PRO for PIC32\Examples\Development Systems\EasyPIC Fusion v7\USB
For PIC24:
\Mikroelektronika\mikroC PRO for dsPIC\Examples\Development Systems\EasyPIC Fusion v7\PIC24EP512GU810\USB

Kind regards,
Jovana

pic32user
Posts: 23
Joined: 23 Apr 2013 13:58

Re: PIC24 USB Host Mode

#5 Post by pic32user » 09 May 2019 15:12

I am using the EasyPIC Fusion V7 board. I have looked at the examples but the software description say they are for a HID device plugged into a PC. I'm looking for the PC side of it so I can plug the HID to it, see if its connected, send it a command and read the response back. My device plugs into the USB Host (Type A) of the board. Thanks......

User avatar
jovana.medakovic
mikroElektronika team
Posts: 986
Joined: 18 Dec 2018 10:36

Re: PIC24 USB Host Mode

#6 Post by jovana.medakovic » 10 May 2019 09:13

Hello,

Can you tell me which MCUs you are using?

When you install examples from the link which I sent you:
https://libstock.mikroe.com/projects/vi ... st-library
You can find these examples on the path:
\Mikroelektronika\mikroC PRO for dsPIC\Packages\USB_Host_dsPIC\Examples\PIC24EP512GU810\Host MSC

Kind regards,
Jovana

pic32user
Posts: 23
Joined: 23 Apr 2013 13:58

Re: PIC24 USB Host Mode

#7 Post by pic32user » 10 May 2019 12:48

I have tried to use those examples (mouse and memory stick) and neither one of them compile. I load the hex file into my Easyfusion V7 board and still get nothing. I am using a PIC24EP512GU810. I attached a picture of the board I am using.
Attachments
EasyFusion.jpg
EasyFusion.jpg (166.44 KiB) Viewed 4314 times

User avatar
jovana.medakovic
mikroElektronika team
Posts: 986
Joined: 18 Dec 2018 10:36

Re: PIC24 USB Host Mode

#8 Post by jovana.medakovic » 10 May 2019 16:08

Hello,

I tested Host_MSC example with PIC24EP512GU810 and it works fine (see the picture in the attachment).

You have to place SD card on USB HOST and turn on SW14.7 switch for USB-PSW.
In user manual of your board, you can read how to use USB HOST (page 24)
https://download.mikroe.com/documents/f ... -v101b.pdf

In the attachment, you can find the example.

Kind regards,
Jovana
Attachments
HOST.zip
(1.89 MiB) Downloaded 113 times

pic32user
Posts: 23
Joined: 23 Apr 2013 13:58

Re: PIC24 USB Host Mode

#9 Post by pic32user » 10 May 2019 18:59

Your hex file works but when I go to compile it I get errors.
Attachments
errors.jpg
errors.jpg (49.54 KiB) Viewed 4303 times
errors.jpg
errors.jpg (49.54 KiB) Viewed 4303 times

User avatar
jovana.medakovic
mikroElektronika team
Posts: 986
Joined: 18 Dec 2018 10:36

Re: PIC24 USB Host Mode

#10 Post by jovana.medakovic » 13 May 2019 10:48

Hello,

Please, go to Project -> Edit Search Path and in Source Path add path to MSCHost_dsPIC_EP.c:
\Mikroelektronika\mikroC PRO for dsPIC\Packages\USB_Host_dsPIC\Uses

Kind regards,
Jovana

pic32user
Posts: 23
Joined: 23 Apr 2013 13:58

Re: PIC24 USB Host Mode

#11 Post by pic32user » 13 May 2019 20:07

I did what you asked and now I get this error...
Attachments
error2.jpg
error2.jpg (57.48 KiB) Viewed 4249 times

pic32user
Posts: 23
Joined: 23 Apr 2013 13:58

Re: PIC24 USB Host Mode

#12 Post by pic32user » 13 May 2019 20:09

I don't understand because the example is not using a multi media card.

User avatar
jovana.medakovic
mikroElektronika team
Posts: 986
Joined: 18 Dec 2018 10:36

Re: PIC24 USB Host Mode

#13 Post by jovana.medakovic » 14 May 2019 09:17

Hello,

Unfortunately, I cannot reproduce the same behavior.
Please, try to uncheck the MMC library from the Library Manager.
Can you tell me which version of the compiler you are using?

Kind regards,
Jovana

abdul95
Posts: 1
Joined: 04 Oct 2022 13:10

Re: PIC24 USB Host Mode

#14 Post by abdul95 » 04 Oct 2022 13:20

I'm trying to configure the PIC24FJ128GC010 for USB host mode. i want to connect mouse or keyboard with USB host port of PIC24FJ128GC010. So please share me the correct example code and please explain how to access those links. i have already checked in the comments where you shared some links but i don't have any idea how to access those links in mplab x ide.

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

Re: PIC24 USB Host Mode

#15 Post by filip » 12 Oct 2022 09:47

Hi,

Have you installed USB Host library from LibStock :
https://libstock.mikroe.com/projects/vi ... st-library

Regards,
Filip.

Post Reply

Return to “mikroC PRO for dsPIC30/33 and PIC24 General”