Mike said:
Chris,
Thank you for the encouragement. I downloaded the eegeek software but I'm afraid it's way over my head. I can't even get the MCHPUSB.mcp project file to open up in my MPLAB to look at the files.
Mike
Instead of eekgeek, Try the pic coder files instead. I know they work, because ive tested them.
I know that the framework looks scary
, believe me, i put off learning about usb with 18f because of that. If you look at it carefully, and trace through it using mplab sim, you will see that there is not much that needs
modifying.
The framework is structured in such a way, that most of the code that you need to modify, is contained within the files called user. (user.c & user.h)
I would advise you to start off by looking at the following files/methods:
User.h > DATA_PACKET
Code:
typedef union DATA_PACKET
{
byte _byte[USBGEN_EP_SIZE]; //For byte access
word _word[USBGEN_EP_SIZE/2];//For word access(USBGEN_EP_SIZE msut be even)
struct
{
enum
{
READ_VERSION = 0x00,
ID_BOARD = 0x31,
The enum is for command hex codes. If you wanted to add a new command to the framework, you would simply define another enum member with a unique hex.
i.e you could have "FLASHLED = 0x1A,". You would then need to get the pc to send 0x1A to flash the led.
User.C > ServiceRequests()
This is where you do something with the enum value that you defined before.
It basically just contains a case statement (like an If, else statement combined)
For my example above, you would add a case statement (following the convention set out in the code). i.e case FLASHLED: <HANDLERCODE>; break;
The compiler will replace FLASHLED with 0x1A:.
Code:
void ServiceRequests(void)
{
if(USBGenRead((byte*)&dataPacket,sizeof(dataPacket)))
{
counter = 0;
switch(dataPacket.CMD)
{
case READ_VERSION:
//dataPacket._byte[1] is len
dataPacket._byte[2] = MINOR_VERSION;
dataPacket._byte[3] = MAJOR_VERSION;
counter=0x04;
break;
To get the project to compile, you need to have microchip C18 compiler installed, and mplab configured to use it.
You will need to alter the project specific file paths, otherwise the compiler will look in the wrong directories when compiling.
If memory serves me correctly, i think that the paths are set up to use the G:\ drive. My G drive is a dvd drive, so obviously these paths need to be updated.
I have included a few screenshots to help you, in case you dont understand what im going on about.
You should make a board, as described by the site, ensuring that you use a capactitor as described on vUSB pin. You also need to make sure that you implement the pin that 'senses' the usb bus (connected to the usb bus v+), if you dont do this (as i didnt) you need to modify the code to not expect the pin which tests whether usb is connected. If you follow the circuit diagram exactly, you will find it easier to get the code working.
right mate, that should get you started (hopefully
).
If you can't get it working, ill try and help you