The Processor Expert USB CDC component posted in USB or not: CDC with Processor Expert has found many friends :-). A new version is available for download here with examples. It adds a bunch of new features and makes many things: simpler dependencies and setup, generation of an easily accessible cdc.inf and availability of error hooks. I have it running now with the TWR-MCF52259 and the DEMOJM (MCF51JM128 and S08JM60).
- The Init_USB component is now an inherited component. The settings for the Init component are automatically set up at creation time.So adding FSL_USB_Stack just needs two things to configure: the CPU and the Init_USB:
- The component generates the Windows driver .inf file into the Documenation folder, based on the component settings. The cdc.inf is a combined file supporting both 32bit and 64bit Windows machines:
- The .inf and the code generation supports now many settings, including PID/VID:
- The component has an optional OnError() hook which catches common errors:
- Many small improvements and fixes.
Note: The post in USB or not: CDC with Processor Expert is updated to reflect the changes and improvements.
Happy CDCing 🙂
Pingback: FSL_USB_Stack updated: sending 16 or 32 byte blocks | MCU on Eclipse
FYI, I’m working right now on support for the S08MM128. Post a comment or follow this post and you get notified once the updated stack is available.
LikeLike
Pingback: USB CDC goes medical | MCU on Eclipse
Pingback: Tutorial: USB CDC with the KL25Z Freedom Board | MCU on Eclipse
Hi Erich, I just updated from your github, and updated MCU10.5 with the updates from Freescale for the PE, etc. (and FSL USB stack 4.1.1) and (after adding critical sections) I’m getting these two errors :
Generator: FAILURE: at line 5: Error in including “Drivers\FSL_USB_Stack\FSL_USB_Stack_Config.h” (file: Drivers\FSL_USB_Stack_Files.prg) ips-hwtest USB1 Processor Expert Problem
Generator: FAILURE: at line 54: Unknown macro: “UseUSBStackInitialization” (file: Drivers\FSL_USB_Stack\Device\app\cdc\user_config.h) ips-hwtest CDC1 Processor Expert Problem
So if I click on the first one and the line is:
%include FSL_USB_Stack\FSL_USB_Stack_Config.h
… which is odd because there is no file Drivers\FSL_USB_Stack\FSL_USB_Stack_Config.h in Processor Expert/CWMCU_PE5_00….
And the second on is pure mystery…
LikeLike
Hi Marc,
sorry about that. I knew it will have an effect on other components, but thought it should work. I’ll have a look right now.
LikeLike
Hi Marc,
I don’t see your problem on my side? I will go through all my projects on GitHub and add the CriticalSection component to it, and publish my latest components later today. Have you tried to exit CodeWarrior and restarted it to see if the issue goes away?
LikeLike
Hi Marc,
I realize that I have not pushed one file to GitHub for the updated RingBuffer component. Maybe this is causing your troubles?
https://github.com/ErichStyger/mcuoneclipse/commit/6e824a3d5588a5e6251f29c75e133eb9515611b2
LikeLike
Hi just updated, and I still have the same problem. I don’t think it’s related to the CriticalSection component, it looks like something to do with the FSL USB stack? Am I looking in the wrong spot for FSL_USB_Stack_Config.h because I don’t see that in Processor Expert\CWMCU_PE5_00\Drivers\FSL_USB_Stack\.
I’m under the impression that Drivers\FSL_USB_Stack is created from installing Freescale_USB_Stack_v4.1.1?
LikeLike
Hi Marc,
I think I know now what the problem is. I contact you directly to get it resolved.
Erich
LikeLike
Hi Erich, do you think that work the usb cdc to connect in the raspberry PI? I mean, I dont want to use a USB Serial chip converter like FTDI, the OS that I’ll be use is raspbian, do you think that works? thanks, best regards
LikeLike
Yes, that should work as long the RasPi USB implements a USB CDC Host class.
LikeLike
Thanks Erich, I’ll be probe, and telling if works, again Thanks for your repply, and congrats for you participation in FTF americas
LikeLike
Hi Erich,
Came across this ‘issue’ with the CDC_usb_Device component. everything runs fine when the usb is enumerated. but when i unplug the usb it remains in the while loop in CDC1_SendDataBlock:
is there some way to detect the usb unplug and prevent this from happening?
uint8_t CDC1_SendDataBlock(uint8_t *data, uint16_t dataSize)
{
uint8_t res = ERR_OK;
transactionOngoing = TRUE;
if (USB_Class_CDC_Interface_DIC_Send_Data(CONTROLLER_ID, data, dataSize)!=USB_OK) {
transactionOngoing = FALSE;
return ERR_FAULT;
}
/* wait for transaction finish */
while(transactionOngoing) { /* wait until transaction is finished */
/*lint -save -e522 function lacks side-effects */
CDC1_RunUsbEngine();
/*lint -restore */
}
return res;
}
LikeLike
Hi David,
if you are using my latest components from SourceForge: a while ago I have implemented a timout option you can turn on for SendDataBlock() in the component properties. Then it uses a timeout like this:
uint8_t CDC1_SendDataBlock(uint8_t *data, uint16_t dataSize)
{
TMOUT1_CounterHandle timeout;
uint8_t res = ERR_OK;
transactionOngoing = TRUE;
if (USB_Class_CDC_Interface_DIC_Send_Data(CONTROLLER_ID, data, dataSize)!=USB_OK) {
transactionOngoing = FALSE;
return ERR_FAULT;
}
/* wait for transaction finish */
timeout = TMOUT1_GetCounter(50/TMOUT1_TICK_PERIOD_MS); /* set up timeout counter */
while(transactionOngoing) { /* wait until transaction is finished */
/*lint -save -e522 function lacks side-effects */
CDC1_RunUsbEngine();
/*lint -restore */
if (TMOUT1_CounterExpired(timeout)) {
res = ERR_FAILED;
break;
}
WAIT1_WaitOSms(10); /* wait some time */
}
TMOUT1_LeaveCounter(timeout); /* return timeout counter */
return res;
}
See https://github.com/ErichStyger/mcuoneclipse/commit/d0f99ca66684120b916c9bf402d8acc95429093b what I have done. You need a periodic timer (e.g. 10ms) and call TMOUT1_AddTick() too.
I hope this helps,
Erich
LikeLike
yes thanks! that’s perfect.
LikeLike
hi Erich,
the following function get stuck in it’s while loop after i unplug the usb cable.
uint8_t CDC1_SendDataBlock(uint8_t *data, uint16_t dataSize)
.
.
while(transactionOngoing) { /* wait until transaction is finished */
/*lint -save -e522 function lacks side-effects */
CDC1_RunUsbEngine();
/*lint -restore */
}
.
.
.
is there some way to detect a disconnect of the cable so this does not happen? i put a breakpoint to the usb_isr and it breaks there when plugging the cable, but not unplugging.
thanks
david
LikeLike
Hi David,
I tried many times to correclty detect the disconnect of the USB cable. It never worked in a reliable way for me.
Erich
LikeLike
bummer. well, no biggie. thanks for the help!
LikeLike