Simplified Microchip PIC USB demos (C18/XC8 MLA)

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby vloki » Wed Apr 22, 2015 11:36 am

TC49 wrote:Your xxxr2 at the top of this topic and mla 2013_12_20

r2 -> MLA v2014_07_22 +PIC18F25K50 ?
vloki
Verified identity
 
Posts: 186
Joined: Wed May 28, 2014 8:42 am
Location: Germany
PIC experience: Professional 5+ years with MCHP products

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby plotino » Sat May 23, 2015 3:47 pm

thanks vloki
i m trying to compile your simplified pic usb demo to begin with pic usb.
but i got in mplabx linker error :
:0: error: undefined symbols:
in
_USBDeviceTasks(dist/default/production/HID_simple.X.production.obj)
_RemoteWakeup(dist/default/production/HID_simple.X.production.obj)
_mLED_3_On(dist/default/production/HID_simple.X.production.obj)
_mLED_4_On(dist/default/production/HID_simple.X.production.obj)
_USBBusIsSuspended(dist/default/production/HID_simple.X.production.obj)
_mLED_3_Off(dist/default/production/HID_simple.X.production.obj)
_mLED_4_Off(dist/default/production/HID_simple.X.production.obj)
_initSpecialEventTrigger(dist/default/production/HID_simple.X.production.obj)
_mInitAllLEDs(dist/default/production/HID_simple.X.production.obj)
_initCLKPLL(dist/default/production/HID_simple.X.production.obj)
_mInitPoti(dist/default/production/HID_simple.X.production.obj)
_mLED_3_Toggle(dist/default/production/HID_simple.X.production.obj)
_initADC(dist/default/production/HID_simple.X.production.obj)
_USBDeviceInit(dist/default/production/HID_simple.X.production.obj)
_mGetSwitch(dist/default/production/HID_simple.X.production.obj)
_USBDeviceAttach(dist/default/production/HID_simple.X.production.obj)
_USBTransferOnePacket(dist/default/production/HID_simple.X.production.obj)
_USBDeviceState(dist/default/production/HID_simple.X.production.obj)
_mInitSwitch(dist/default/production/HID_simple.X.production.obj)
Microchip MPLAB XC8 C Compiler V1.12


can u help me?

ciao

plot
plotino
 
Posts: 1
Joined: Sat May 23, 2015 3:35 pm

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby vloki » Sat May 23, 2015 5:20 pm

The name of my project is not HID_simple. What have you done ?
Better you try to compile it without making modifications for the beginning !

<edit> xc8 v1.12 ? Why do you use such old version ?
vloki
Verified identity
 
Posts: 186
Joined: Wed May 28, 2014 8:42 am
Location: Germany
PIC experience: Professional 5+ years with MCHP products

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby Mystievel » Tue Jun 02, 2015 2:49 am

Hi Vloki,

I tried running the program with the PIC18F4550 and everything compiled wonderfully, no changes were needed, just opened up the project in MPLAB X v3.00, selected the correct configuration, and was good to go.

But how would one go about configuring this project for another microcontroller such as the PIC18F2550?

Thank you!

*****EDIT*****
Holy crap, I can't believe I actually got something to work! (Note: this has only been tested as far as my PC recognizing the device as a COM port and establishing a connection through HyperTerminal; I have yet to test sending and receiving data to and from the PIC)

Here is what I did to configure my PIC18F2550 from your project (hopefully I wasn't wasting my time...please let me know if there was a faster way!)
1) I opened up your project LPC_FSUSB-CDC-X-r2.zip in MPLAB X v3.00
2) I created my own configuration for the microcontroller I am using PIC18F2550 using PICKIT3 and XC8.
3) Under project properties -> my configuration -> XC8 compiler, I copied the "Include Directories" that the other configuration settings had "./" "./plib" and "../mla/v2014_07_22/framework"
4) I also edited the PicKit3 power configuration "Power" to power the target using the PicKit3 (not sure if this was necessary since I swap from the PicKit3 usb cable to an actual usb connected directly to my PIC after programming to talk to the PC)
5) Under my project folder "...\src\BSP-FILES" I created a file for the pic18f2550 (copy and pasted from the 4550 header and source files) and just did a "replace all" from "4550" to "2550".
6) In addition to the step above, I edited every other file that had "4550" in it to include the appropriate text for the "2550" as well. I don't remember what files exactly, for sure the "system.h" and "usb_descriptors.c" files located under "...src\LPC_FSUSB-CDC-X"
7) Then in MPLAB X I built the project and made modifications as needed. These included REMOVING all of the BSP files (both source and header) that I wasn't using, and ADDING the pic18f2550 header and source bsp files.
8) I still had one error in my configuration, where the compiler didn't recognize "ICSP" or something of the sort for the in-circuit serial debugger or w/e, I simply changed this to "DEBUG" and everything compiled just file!
9) Then I programmed my device, disconnected my pickit, connected a regular usb cable to my circuit, manually loaded the driver (didnt let windows vista look for it) by locating the directory that contained "mchpcdc.inf".

...Again if there was an easier way, please let me know! But hopefully this can help someone in the future. (hopefully this actually works..again I haven't done anything besides get a "device is working properly" "COM4 detected" in my device manager.

Best.

*****EDIT 2*****
Finally got around to testing. Yeup, all works fine and dandy. Just threw this code up above main
Code: Select all
BYTE buffer[64];
BYTE numBytes;

and threw this code at the bottom of the while loop (After declaring TRISA = 0; and PORTA = 0;):
Code: Select all
numBytes = getsUSBUSART(buffer,sizeof(buffer)); //until the buffer is free.
        if(numBytes > 0) {
         if(buffer[0] == 'a') {
            LATAbits.LATA1 = 1;
         }
         //we received numBytes bytes of data and they are copied into
         // the "buffer" variable.  We can do something with the data here.
        }
Last edited by Mystievel on Thu Jun 04, 2015 2:25 am, edited 2 times in total.
Mystievel
 
Posts: 1
Joined: Tue Jun 02, 2015 2:46 am

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby vloki » Tue Jun 02, 2015 8:29 am

Very good description ;-)
Even this "simplified" project is still a bit complex because of all the different configurations for pics and compilers
I think it is a little bit more easy to understand than the original.

2) If you'd copy the configuration and renamed it, you possibly copied the path settings as well.

7) Guess you deleted the configurations as well

8) You mean #pragma config ICPRT = OFF ?
This is only available with 44pin 18F4550 TQFP where you can set the ISP to the additional four (free) pins
vloki
Verified identity
 
Posts: 186
Joined: Wed May 28, 2014 8:42 am
Location: Germany
PIC experience: Professional 5+ years with MCHP products

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby Max » Fri Jul 24, 2015 5:06 pm

Hi,

Thank you so much for providing this USB project, vloki. I had been fiddling with it a lot for past few days and, finally, I found you. I downloaded and set up your project for PIC 18F13k50. I did some changes in header files for PIC 18F13k50 and all compiled well.

As soon as I connect PIC to PC via USB, PC identifies device as 'USB INPUT Device' with --->13k50. So it works. Now to the question, how do I send and receive data b/w PC and USB. Or how do I turn on/off led via changing data in the DATA BUFFER of USB so that I'm sure that it's working 100%.

I'm sorry I'm a beginner so I thought of asking you. And thank you so much.

Regards.
Max
 
Posts: 3
Joined: Fri Jul 24, 2015 2:53 pm

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby vloki » Sat Jul 25, 2015 2:13 pm

Which project did you choose. The HID or the CDC ?
vloki
Verified identity
 
Posts: 186
Joined: Wed May 28, 2014 8:42 am
Location: Germany
PIC experience: Professional 5+ years with MCHP products

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby Max » Mon Jul 27, 2015 6:01 am

I chose HID. Later what I want to do is read ADC value and pass that ADC value to the USB buffer. This buffer can be read by software in Computer which stores this value into the text file. I had made software in C# .NET, but it used to identify this circuit when I programmed it with mikroC using other USB firmware. So, that's why I asked how to test.

Thanks.
Max
 
Posts: 3
Joined: Fri Jul 24, 2015 2:53 pm

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby vloki » Mon Jul 27, 2015 8:17 am

Sorry, no C# here ;-)
There is an example in C++ (Qt) in post #4 of this thread.
Other C++ examples (vC++ 2005 express and Qt) are included in the microchip libraries for applications.

<edit>
OK, may be you will find some useful information on Jan.net's page
-> http://janaxelson.com/hidpage.htm

I added an executable of my Qt example here ->
YOU NEED THE ZIP WITH THE DLLs AS WELL.
PUT THE EXE INTO THE FOLDER WITH THE DLLs !!!
</edit>
vloki
Verified identity
 
Posts: 186
Joined: Wed May 28, 2014 8:42 am
Location: Germany
PIC experience: Professional 5+ years with MCHP products

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby Max » Mon Jul 27, 2015 11:06 am

Great link! I think I'll find how to integrate USB drivers with C# project to play with circuit via USB. Thanks! And I tested circuit using your software. I was able to switch OFF/ON LED. As I click on Switch ON, then Input HEX reads: 1 b1, and 1 b0 for OFF. But when I click Device or Version, it reads: 1 ff, for both the options. And it doesn't display the info in the software. So something might be wrong in passing input from the software to the circuit, I guess?

BTW, which USB driver did you use for implementing your software? Did use Windows' built-in HID drivers to communicate with device? Again thanks a lot for replying and helping me out. Appreciate it a lot.
Max
 
Posts: 3
Joined: Fri Jul 24, 2015 2:53 pm

PreviousNext

Return to USB

Who is online

Users browsing this forum: No registered users and 7 guests

cron