Conversion of C18 USB CDC firmware
Conversion of C18 USB CDC firmware
Hello everyone!
Got bored this weekend and decided I would translate Microchips latest
C18 library for USB CDC into mikroC.
The translation went ok, kind of, at least there are not compiler errors,
so it compiles just fine!
But (there is always a but)! It doesn't work. The device is found my
Windows Vista but as an "unknown device" in the Device Manager. I've
been using SourceUSB to see the communications with the device and it
fails when the PC is requesting the descriptor from the PIC.
After looking into it some I've found out that for what ever reason the
program doesn't continue to line 277 in the usbdrv.c that calls for a
function that is supposed to dealt with the enumeration...
I figured, as there are many of us that wants CDC in mikroC why not
help each other out on this one?
The source can be found here:
http://otio.se/~jonas/cdc.rar
Before you open the mikroC project in the "Cdc"-folder you have to copy
the P18F4550CDC.* files to you mikroC\defs folder. I've disabled the
loading of the mikroC HID library in those files.
I've also added the original C18 library, in the "MC_CDC"-folder.
In the "inf"-folder you can find a *.inf file to be used when installing the
drivers (when everything works). You can use it if you are testing the
C18 lib. The MCHPUSB.hex is compiled and works with PIC18F4550
running with a 20MHz crystal. Worked for me yesterday with EasyPIC5.
The mikroC project is configured to make the PIC18F4550 run at 48MHz
on a 20MHz crystal.
So, what do you say? Are we gonna make this work or what?
Got bored this weekend and decided I would translate Microchips latest
C18 library for USB CDC into mikroC.
The translation went ok, kind of, at least there are not compiler errors,
so it compiles just fine!
But (there is always a but)! It doesn't work. The device is found my
Windows Vista but as an "unknown device" in the Device Manager. I've
been using SourceUSB to see the communications with the device and it
fails when the PC is requesting the descriptor from the PIC.
After looking into it some I've found out that for what ever reason the
program doesn't continue to line 277 in the usbdrv.c that calls for a
function that is supposed to dealt with the enumeration...
I figured, as there are many of us that wants CDC in mikroC why not
help each other out on this one?
The source can be found here:
http://otio.se/~jonas/cdc.rar
Before you open the mikroC project in the "Cdc"-folder you have to copy
the P18F4550CDC.* files to you mikroC\defs folder. I've disabled the
loading of the mikroC HID library in those files.
I've also added the original C18 library, in the "MC_CDC"-folder.
In the "inf"-folder you can find a *.inf file to be used when installing the
drivers (when everything works). You can use it if you are testing the
C18 lib. The MCHPUSB.hex is compiled and works with PIC18F4550
running with a 20MHz crystal. Worked for me yesterday with EasyPIC5.
The mikroC project is configured to make the PIC18F4550 run at 48MHz
on a 20MHz crystal.
So, what do you say? Are we gonna make this work or what?
Jonas Andersson, Sweden
EasyPIC3, EasyPIC5, various dev boards and fully licensed mikroC
"It's nice to be important, but it's more important to be nice"
EasyPIC3, EasyPIC5, various dev boards and fully licensed mikroC
"It's nice to be important, but it's more important to be nice"
Been on this for another 12 hours and I can't get it to work.
The PIC seems to get stuck in the USB default state.
Isn't there anyone that is as interneted as me to get this to work?
Or maybe mikroE is wokring on a CDC library for mikroC, mikroBasic and mikroPascal?
The PIC seems to get stuck in the USB default state.
Isn't there anyone that is as interneted as me to get this to work?
Or maybe mikroE is wokring on a CDC library for mikroC, mikroBasic and mikroPascal?
Jonas Andersson, Sweden
EasyPIC3, EasyPIC5, various dev boards and fully licensed mikroC
"It's nice to be important, but it's more important to be nice"
EasyPIC3, EasyPIC5, various dev boards and fully licensed mikroC
"It's nice to be important, but it's more important to be nice"
I want more informastion
Hi, XorXaX!
I'm interested in your work.
I try comile your code, but I could not compile it because compiling error...
error:Operator [.] not applicable to this operands [SetupPkt]
what is "SetupPkt"? where is definition of SetupPkt?
I'm interested in your work.
I try comile your code, but I could not compile it because compiling error...
error:Operator [.] not applicable to this operands [SetupPkt]
what is "SetupPkt"? where is definition of SetupPkt?
Re: Conversion of C18 USB CDC firmware
Thanks for your interest!
To quote my self:
device for this project, this is because I have disable the HID library in
this device definition file.
In mikroE's USB HID library they define their own SetupPkt, thus can't we
use that variable in this CDC library, unless we disable it, that I have
done in my def files.
Try this again and let me know if it works better to compile.
To quote my self:
You have to copy these definitions files and use the PIC18F4550CDC asXorXaX wrote: Before you open the mikroC project in the "Cdc"-folder you have to copy
the P18F4550CDC.* files to you mikroC\defs folder. I've disabled the
loading of the mikroC HID library in those files.
device for this project, this is because I have disable the HID library in
this device definition file.
In mikroE's USB HID library they define their own SetupPkt, thus can't we
use that variable in this CDC library, unless we disable it, that I have
done in my def files.
Try this again and let me know if it works better to compile.
Jonas Andersson, Sweden
EasyPIC3, EasyPIC5, various dev boards and fully licensed mikroC
"It's nice to be important, but it's more important to be nice"
EasyPIC3, EasyPIC5, various dev boards and fully licensed mikroC
"It's nice to be important, but it's more important to be nice"
Hi Jonas,
I'm tested your work, it is a really nice work !
Even in my PC (Vista32) the hardware is not recognized. However during compilation with MikroC I see this message:
occurred in lines 150 and 156 of usb9.c that is this istructions:
I am investigating ... but is a hard work for a beginner like me !
I'm tested your work, it is a really nice work !
Even in my PC (Vista32) the hardware is not recognized. However during compilation with MikroC I see this message:
Code: Select all
- pointer conversion to int type
Code: Select all
*pSrc.bRom = *(USB_CD_Ptr + SetupPkt.e.bDscIndex);
... then ... I'm working.So, what do you say? Are we gonna make this work or what?
Hi pdo59!
yeah, that pointer thingy, I have no idea how to get rid of it. I don't think
that is the problem casing the computer not to recognize it (but I'm not sure).
Maybe someone else does?
yeah, that pointer thingy, I have no idea how to get rid of it. I don't think
that is the problem casing the computer not to recognize it (but I'm not sure).
Maybe someone else does?
Jonas Andersson, Sweden
EasyPIC3, EasyPIC5, various dev boards and fully licensed mikroC
"It's nice to be important, but it's more important to be nice"
EasyPIC3, EasyPIC5, various dev boards and fully licensed mikroC
"It's nice to be important, but it's more important to be nice"
Hello Jonas,
right, this is not the problem.
However in this manner the compiler don't send a warning :
right, this is not the problem.
However in this manner the compiler don't send a warning :
Code: Select all
*pSrc.bRom = *(*USB_SD_Ptr + SetupPkt.e.bDscIndex);
Yepp, compiles without complains now, thanks for that.
I think the problem is that the UIR.TRNIF (the USB Transfer Complete Flag)
never seems to be asserted for whatever reason. And since this never gets
asserted, and the computer doesnt recognize the device it must mean that
for whatever reason the SETUP Token doesn't get through to alright in the
PIC or the PC never sends it... See PIC18F4550 datasheet, figure 17-9,
page 177.
See usbdrv.c line 303, that if-case is never run
I think the problem is that the UIR.TRNIF (the USB Transfer Complete Flag)
never seems to be asserted for whatever reason. And since this never gets
asserted, and the computer doesnt recognize the device it must mean that
for whatever reason the SETUP Token doesn't get through to alright in the
PIC or the PC never sends it... See PIC18F4550 datasheet, figure 17-9,
page 177.
See usbdrv.c line 303, that if-case is never run
Jonas Andersson, Sweden
EasyPIC3, EasyPIC5, various dev boards and fully licensed mikroC
"It's nice to be important, but it's more important to be nice"
EasyPIC3, EasyPIC5, various dev boards and fully licensed mikroC
"It's nice to be important, but it's more important to be nice"
Hi there,
I have not seen Xorxax' translation job,but I am quite interested, as it could be useful in near future.
As far as I have seen, I believe that the mistake in the code below could be in SetupPkt.e.bDscIndex
So, from
*pSrc.bRom = *(*USB_SD_Ptr + SetupPkt.e.bDscIndex);
you could try
*pSrc.bRom = *(USB_SD_Ptr + SetupPkt->e.bDscIndex);
This is be because if "e" is a structure or an union, then "bDscIndex" is its member. However "e" is also a member of the structure/union of SetupPkt.
To directly access bDscIndex (from "e"), here's an example:
variable= e.bDscIndex
To access bDscIndex from SetupPkt (indirect access), then
variable= SetupPkt->e.bDscIndex
Please, let me know if it works,
Regards,
Falcon
I have not seen Xorxax' translation job,but I am quite interested, as it could be useful in near future.
As far as I have seen, I believe that the mistake in the code below could be in SetupPkt.e.bDscIndex
So, from
*pSrc.bRom = *(*USB_SD_Ptr + SetupPkt.e.bDscIndex);
you could try
*pSrc.bRom = *(USB_SD_Ptr + SetupPkt->e.bDscIndex);
This is be because if "e" is a structure or an union, then "bDscIndex" is its member. However "e" is also a member of the structure/union of SetupPkt.
To directly access bDscIndex (from "e"), here's an example:
variable= e.bDscIndex
To access bDscIndex from SetupPkt (indirect access), then
variable= SetupPkt->e.bDscIndex
Please, let me know if it works,
Regards,
Falcon
Thanks for the suggestion Falcon, one could have hoped it would be that easy, but since SetupPkt isn't a pointer and just a global variable, we are supposted to use the . instead of the -> ...
If using the -> the code wont even compile.
If using the -> the code wont even compile.
Jonas Andersson, Sweden
EasyPIC3, EasyPIC5, various dev boards and fully licensed mikroC
"It's nice to be important, but it's more important to be nice"
EasyPIC3, EasyPIC5, various dev boards and fully licensed mikroC
"It's nice to be important, but it's more important to be nice"
Hi Falcon,
your advice is correct, (I think), but the compiler reply:
Thank you for your appreciate help; if you can, help us in this work trying to compile the XorXaX code.
your advice is correct, (I think), but the compiler reply:
Code: Select all
Pointer required
Some time ago I was able to complete de 'translation' of the Microchip CDC to MikroC, based on a job by Rotendje (take a look at http://www.mikroe.com/forum/viewtopic.php?t=11424).
Unfortunelly, I stopped at the same point: the USB device is detected but halts after a few seconds. Did someone got beyond this point?
regards,
Lutcho
Unfortunelly, I stopped at the same point: the USB device is detected but halts after a few seconds. Did someone got beyond this point?
regards,
Lutcho