Hi. I'm using a ECIO28P for my project to control a DC motor using a user friendly program (using Microsoft visual express c#) via USB. I'm currently trying to get the module to be recognised as a HID device using the MCHPFSUSB firmware from Microchip with no luck. I've edited the code as if it were designed for the PIC18f2455. The program builds succesfully in MPLAB but not getting a activity when i load the program onto the ECIO module.
Would there be specific changes to account for using the p18f2455 on the ECIO28p? or would the program's configuration be exactly as if i was using a standalone pic18f2455?
The more obvious question is whether its possible to do what i'm attempting to do? The reason i ask is because i noticed that the USB pins are not found on the module since the USB socket is already integrated.
Also, i havent configured the config bits in case it affected the bootloader. I was thinking of using the settings the firmware uses for the P18f4550 shown below:
#if defined(PICDEM_FS_USB) // Configuration bits for PICDEM FS USB Demo Board (based on PIC18F4550)
#pragma config PLLDIV = 5 // (20 MHz crystal on PICDEM FS USB board)
#pragma config CPUDIV = OSC1_PLL2
#pragma config USBDIV = 2 // Clock source from 96MHz PLL/2
#pragma config FOSC = HSPLL_HS
#pragma config FCMEN = OFF
#pragma config IESO = OFF
#pragma config PWRT = OFF
#pragma config BOR = ON
#pragma config BORV = 3
#pragma config VREGEN = ON //USB Voltage Regulator
#pragma config WDT = OFF
#pragma config WDTPS = 32768
#pragma config MCLRE = ON
#pragma config LPT1OSC = OFF
#pragma config PBADEN = OFF
// #pragma config CCP2MX = ON
#pragma config STVREN = ON
#pragma config LVP = OFF
// #pragma config ICPRT = OFF // Dedicated In-Circuit Debug/Programming
#pragma config XINST = OFF // Extended Instruction Set
#pragma config CP0 = OFF
#pragma config CP1 = OFF
// #pragma config CP2 = OFF
// #pragma config CP3 = OFF
#pragma config CPB = OFF
// #pragma config CPD = OFF
#pragma config WRT0 = OFF
#pragma config WRT1 = OFF
// #pragma config WRT2 = OFF
// #pragma config WRT3 = OFF
#pragma config WRTB = OFF // Boot Block Write Protection
#pragma config WRTC = OFF
// #pragma config WRTD = OFF
#pragma config EBTR0 = OFF
#pragma config EBTR1 = OFF
// #pragma config EBTR2 = OFF
// #pragma config EBTR3 = OFF
#pragma config EBTRB = OFF
I'm using MPLAB c18 compiler to program the p18f2455.
Thanks
Mike
Using Microchip's Usb HID firmware for ECIO 28P
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Using Microchip's Usb HID firmware for ECIO 28P
Hello Mike,
Have you considered using Flowcode. It makes using the USB a walk in the park rather then the treck in the jungle that is the FSUSB library.
The Microchip FSUSB code should however work well on the ECIO devices.
The only thing that is standing out at the moment is that your configuration is set to use a 20MHz crystal whereas the ECIO has a 4MHz crystal onboard.
There may also be a USB detection pin enabled in the Microchip FSUSB software. If you are using this then the pin is RA5 on a ECIO28P.
The default ECIO configuration should work well with the USB code. If you need help then the configuration is set as follows.
Please note that you will need to use the microchip USB examples that includes the edited linker if you are using the C18 compiler to allow the ECIO USB bootloader to work. The code offset for the main program is 0x800. The example linker file in the Microchip examples is for a 18F4550 or a 18F4455 (I cant remember which) if you compile as if you were using this device then the code will still download and run correctly on the 18F2455 device. Otherwise you will probably have to hand edit the 2455 linker file to allow this to work correctly.
If you are using the Hi Tech compiler then please see my notes on this in the Articles section of our forum to allow you to change the compile settings so that the code is automatically offset to 0x800.
Let me know how you get on.
Have you considered using Flowcode. It makes using the USB a walk in the park rather then the treck in the jungle that is the FSUSB library.
The Microchip FSUSB code should however work well on the ECIO devices.
The only thing that is standing out at the moment is that your configuration is set to use a 20MHz crystal whereas the ECIO has a 4MHz crystal onboard.
There may also be a USB detection pin enabled in the Microchip FSUSB software. If you are using this then the pin is RA5 on a ECIO28P.
The default ECIO configuration should work well with the USB code. If you need help then the configuration is set as follows.
Please note that you will need to use the microchip USB examples that includes the edited linker if you are using the C18 compiler to allow the ECIO USB bootloader to work. The code offset for the main program is 0x800. The example linker file in the Microchip examples is for a 18F4550 or a 18F4455 (I cant remember which) if you compile as if you were using this device then the code will still download and run correctly on the 18F2455 device. Otherwise you will probably have to hand edit the 2455 linker file to allow this to work correctly.
If you are using the Hi Tech compiler then please see my notes on this in the Articles section of our forum to allow you to change the compile settings so that the code is automatically offset to 0x800.
Let me know how you get on.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Using Microchip's Usb HID firmware for ECIO 28P
Thanks for the reply! That actually answered my big concern with being able to do this. The reason i cant use flowcode is because this is for my Uni project and the whole idea is to learn how to implement the USB firmware (yes this is very annoying!).
I changed the oscillator to 4 mhz:
#pragma config PLLDIV = 1 ??
I'm not sure if the the detection pin is the same as USB_SENSE:
//#define USE_USB_BUS_SENSE_IO
#define tris_usb_bus_sense TRISAbits.TRISA5 // Input
#if defined(USE_USB_BUS_SENSE_IO)
#define USB_BUS_SENSE PORTAbits.RA5
#else
#define USB_BUS_SENSE 1
#endif
but this is currently turned off with the "//" so it shouldnt effect the program.
I'm using the edited linker file for P184550 which starts like this:
CODEPAGE NAME=boot START=0x0 END=0x7FF PROTECTED
CODEPAGE NAME=vectors START=0x800 END=0x0x829 PROTECTED
CODEPAGE NAME=page START=0x82A END=0x7FFF
Program has built successfully but i'm not getting any activity when i load the program into the ecio module.
I'll try using an edited P18f2455 linker and set the device to P18f2455 in MPLAB instead of P18f4550. If you have any ideas as to why it might not be working(besides what i'm about to change), please let me know.
Cheers
Kind regards
Mike
I changed the oscillator to 4 mhz:
#pragma config PLLDIV = 1 ??
I'm not sure if the the detection pin is the same as USB_SENSE:
//#define USE_USB_BUS_SENSE_IO
#define tris_usb_bus_sense TRISAbits.TRISA5 // Input
#if defined(USE_USB_BUS_SENSE_IO)
#define USB_BUS_SENSE PORTAbits.RA5
#else
#define USB_BUS_SENSE 1
#endif
but this is currently turned off with the "//" so it shouldnt effect the program.
I'm using the edited linker file for P184550 which starts like this:
CODEPAGE NAME=boot START=0x0 END=0x7FF PROTECTED
CODEPAGE NAME=vectors START=0x800 END=0x0x829 PROTECTED
CODEPAGE NAME=page START=0x82A END=0x7FFF
Program has built successfully but i'm not getting any activity when i load the program into the ecio module.
I'll try using an edited P18f2455 linker and set the device to P18f2455 in MPLAB instead of P18f4550. If you have any ideas as to why it might not be working(besides what i'm about to change), please let me know.
Cheers
Kind regards
Mike
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Using Microchip's Usb HID firmware for ECIO 28P
Hello Mike,
Sounds like your 9/10ths of the way there. Does you device do anything i.e. do you get a USB device not recognised message or does the device simply do nothing? If it is doing either of the above then I would imagine that it is the configuration that is to blame.
Are you programming the ECIO via the ECIOprog tool or are you using a PicKIT to program it directly? If your programming it directly it might explain why its not working as expected.
Sounds like your 9/10ths of the way there. Does you device do anything i.e. do you get a USB device not recognised message or does the device simply do nothing? If it is doing either of the above then I would imagine that it is the configuration that is to blame.
Are you programming the ECIO via the ECIOprog tool or are you using a PicKIT to program it directly? If your programming it directly it might explain why its not working as expected.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Using Microchip's Usb HID firmware for ECIO 28P
Hi. It does nothing after programming it. I'm using the ECIOprog tool. Okay thanks, i'm gunna spend time looking at it now and hopefully i'll find something...
Re: Using Microchip's Usb HID firmware for ECIO 28P
Hi Benj! Got it recognising as a Generic HID device now. 
I couldnt seem to get the Mouse demo working so i switched to the Generic HID firmware instead and changed the following:
(1)in main.c...
#pragma config PLLDIV = 1
(2)in Hardware profile - PICDEM FSUSB.h...
#define PROGRAMMABLE_WITH_USB_MCHPUSB_BOOTLOADER
//#define PROGRAMMABLE_WITH_USB_HID_BOOTLOADER
(uncommented the MCHPUSB bootloader and commented the HID bootloader)
(3)and in rm18f4550 - HID Bootload.lkr...
changed:
CODEPAGE NAME=bootloader START=0x0 END=0xFFF PROTECTED
CODEPAGE NAME=vectors START=0x1000 END=0x1029 PROTECTED
CODEPAGE NAME=page START=0x102A END=0x7FFF
to:
CODEPAGE NAME=bootloader START=0x0 END=0x7FF PROTECTED
CODEPAGE NAME=vectors START=0x800 END=0x829 PROTECTED
CODEPAGE NAME=page START=0x82A END=0x7FFF
Thanks alot for your help! Been stuck on this for ages! i'm now going to move onto using the device to transfer and recieve bytes of data..any more trouble i'll let you know
Kind regards
Mike

I couldnt seem to get the Mouse demo working so i switched to the Generic HID firmware instead and changed the following:
(1)in main.c...
#pragma config PLLDIV = 1
(2)in Hardware profile - PICDEM FSUSB.h...
#define PROGRAMMABLE_WITH_USB_MCHPUSB_BOOTLOADER
//#define PROGRAMMABLE_WITH_USB_HID_BOOTLOADER
(uncommented the MCHPUSB bootloader and commented the HID bootloader)
(3)and in rm18f4550 - HID Bootload.lkr...
changed:
CODEPAGE NAME=bootloader START=0x0 END=0xFFF PROTECTED
CODEPAGE NAME=vectors START=0x1000 END=0x1029 PROTECTED
CODEPAGE NAME=page START=0x102A END=0x7FFF
to:
CODEPAGE NAME=bootloader START=0x0 END=0x7FF PROTECTED
CODEPAGE NAME=vectors START=0x800 END=0x829 PROTECTED
CODEPAGE NAME=page START=0x82A END=0x7FFF
Thanks alot for your help! Been stuck on this for ages! i'm now going to move onto using the device to transfer and recieve bytes of data..any more trouble i'll let you know

Kind regards
Mike
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Using Microchip's Usb HID firmware for ECIO 28P
Hi Mike,
Congratulations thats great glad your up and running with it now.
It certainly is a releif and an achievement the first time the USB starts up correctly using the microchip stack
Your question about the "#define USE_USB_BUS_SENSE_IO". Yes this is the same as the USB detection pin so you could try enabling it in the firmware if you want to be able to detect the USB being plugged in etc.
Let me know if you have any further problems using the stack.
Congratulations thats great glad your up and running with it now.
It certainly is a releif and an achievement the first time the USB starts up correctly using the microchip stack

Your question about the "#define USE_USB_BUS_SENSE_IO". Yes this is the same as the USB detection pin so you could try enabling it in the firmware if you want to be able to detect the USB being plugged in etc.
Let me know if you have any further problems using the stack.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel