Page 1 of 10

Simplified Microchip PIC USB demos (C18/XC8 MLA)

PostPosted: Tue Jul 22, 2014 4:29 pm
by vloki
Some projects I created because the original MCHP demo projects in the MLA are unusable for beginners.
This thread is a continuation of Simplified Microchip USB demo projects (HID / CDC; PIC18) in microchip forum.

The packed MPLAB-X projects contain configurations for PIC18 and there are only two files
that depend on the hardware. A header file and a source file in which their names contain PIC and DemoBoard.

Simplified Custom HID Demo project using MLA v2013_12_ 20 / v2014_07_22
Simplified Custom CDC Demo project using MLA v2013_12_ 20 / v2014_07_22

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

PostPosted: Tue Jul 22, 2014 4:29 pm
by vloki
Simplified Custom HID Demo project using MLA v2013_12_ 20 / v2014_07_22

The project contains configurations for PIC18F14K50, PIC18F4550 and PIC18F27J53 and PIC18F25K50
and should compile with C18 and XC8 compiler.


The user part of the firmware is located in the file app_custom_hid.

USB data transfer is handled by APP_CustomHIDTasks() which calls the functions usbIN() and usbOUT().
Data is contained in the ToSendDataBuffer[64] and ReceivedDataBuffer[64].
xBuffer[O] is used for an additional size information of transfered data.

The demo can handle some LEDs and read a poti, a button or internal memory of the PIC.
These actions are controlled in function cmd() which is called during a usb-OUT transaction.

The board/processor specific code is now located in a pair of source/header files located in
a separate folder named "BSP-FILES". (These files are not USB device class specific)

<edit> added PIC18F25K50 and switched to MLA v2014_07_22 -> r2
<edit2> newer versions with newer MLA and more configurations (pic16F145x) are here

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

PostPosted: Tue Jul 22, 2014 4:42 pm
by vloki
Simplified Custom CDC Demo project using MLA v2013_12_ 20 / v2014_07_22

The project contains configurations for PIC18F14K50, PIC18F4550 and PIC18F27J53 and PIC18F25K50 (in r2)
and should compile with C18 and XC8 compiler.
To make it compatible with C18 I had to make some small modifications in the framework
(See C18_changes_in_framework.txt)



The user part of the firmware is located in the file app_custom_cdc.

USB data transfer is handled by APP_CustomCDCTasks()
Data is contained in the usbOutBuffer[64] and usbInBuffer[64];
xBuffer[0] is used for an additional size information of transfered data.

The demo can handle some LEDs and read a poti, a button or internal memory of the PIC.
These actions are controlled in function APP_cmd() which is called during a usb-OUT transaction.

The xx5x_hid.h and xx5x_hid.c files hold the board/processor specific code.


<edit>some modifications with the fixed addresses (while figthing with that d*mn 27j53) -> -r1
<edit2> The framework header "usb_device_local.h" is missing in the package. You can copy it from original MLA

<edit3>switch to MLA v2014_07_22, adding configuration for PIC18F25K50 and move files to the BSP folder -> -r2
<edit4> newer versions with newer MLA and more configurations (pic16F145x) are here

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

PostPosted: Thu Jul 24, 2014 10:14 am
by vloki
Placeholder for new version of cross platform HID terminal
found in previous thread on MCHP forum

<edit2> newer version of this software (inclusive windows exe) is here
<edit> If you use firmware r2 from above, please change the command IDs:
Code: Select all
typedef enum {
    CID_INIT        = 0x00,
    CID_STOP        = 0x01,     // stop sending data
//    CID_CLOSE,
//    CID_OPEN,
//    CID_START       = 0x04,     // send data (continuous)
//    CID_SNGLSHOT    = 0x05,     // send one frame

//    CID_CHANNELS    = 0x06,     //
//    CID_SMPLINTRVL  = 0x07,     // set sampling time (in us)
//    CID_PCKSIZE     = 0x08,     // set package size (continuous)
//    CID_FRAMESIZE   = 0x09,     // set packagesize (single shot)
//    CID_RESOLUTION  = 0x0A,     // set 8bit / 16bit data

    CID_MISC        = 0x0B,     // send miscellanous info-string
    CID_MANU        = 0x0C,     // send developper info-string
    CID_DATE        = 0x0D,     // send date info-string
    CID_VERSION     = 0x0E,     // send version info-string
    CID_DEVICE      = 0x0F,     // send device identification string

//    CID_LED1_OFF    = 0x10,     // LED_1 switch off
//    CID_LED1_ON     = 0x11,     // LED_1 switch on
//    CID_LED1_TOG    = 0x13,     // LED_1 toggle
//    CID_LED1_GET    = 0x15,     // LED_1 get status
//    CID_LED2_OFF    = 0x20,
//    CID_LED2_ON     = 0x21,
//    CID_LED2_TOG    = 0x23,
//    CID_LED2_GET    = 0x25,
    CID_LED3_OFF    = 0x30,
    CID_LED3_ON     = 0x31,
    CID_LED3_TOG    = 0x33,
//    CID_LED3_GET    = 0x35,
    CID_LED4_OFF    = 0x40,
    CID_LED4_ON     = 0x41,
//    CID_LED4_TOG    = 0x43,
//    CID_LED4_GET    = 0x45,

    CID_BUTTON      = 0x50,    // get button state (1 == pressed)
    CID_POTI        = 0x60,    // get analog value
    ID_MESSAGE      = 0x80,
    ID_ERROR        = 0xFF
}COMMANDS;

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

PostPosted: Thu Jul 24, 2014 10:14 am
by vloki
Placeholder for new version of cross platform (CDC) terminal
found in previous thread on MCHP forum

<edit> newer version of this software (inclusive windows exe) is here


Description follows ...

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

PostPosted: Thu Sep 11, 2014 7:14 pm
by giorgik
Hi vloki, interesting your post. I use MLA current: mla_v2014_07_22_windows_installer.exe.
In your post you put only the figure of the HID terminal and you did not put the project or the executable. Would you be so kind as to add, sare very interested in this project, I would be very helpful for my first project based on PIC16F1455 USB HID.Can I possibly ask you to design aids in that I'm doing ?

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

PostPosted: Fri Sep 12, 2014 9:53 am
by vloki
The *newer* version is still in work ;-)
Please click the link in first post to the microchip forum

It's done now ...

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

PostPosted: Thu Oct 16, 2014 10:24 am
by Interrupt
I'm unable to get the project to compile I suspect it's got something to do with my complier settings the compiler is looking in MLA v2014_07_22 instead of MLA v2013_12_20 please see attached .jegs.

Sorry my knowledge of search paths are limited at best, any help would be greatly appreciated :oops:

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

PostPosted: Thu Oct 16, 2014 10:44 am
by vloki
You possibly have to adjust the include directory path ...
screenshot2.png
screenshot2.png (54.6 KiB) Viewed 66425 times

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

PostPosted: Thu Oct 16, 2014 9:39 pm
by Interrupt
I try your suggestion, unfortunately no success! :cry:

if anyone has any ideas please!