Hello, Does anyone have complemented the application of mad-and-cdc composite based on Freescale
USB Stack v4.1.1 for Kinetis M4 MCU? I am trying to do this, but cannot find enough documents like
application notes to help me. Thank you in advance.
Hi Wei Yan,
You can find the procedure for running the MSD+CDC example of Freescale USB Stack on Appendix K of the Freescale USB Device Stack Users Guide document, available at the link below:
Additionally, you could also find several Application Notes regarding USB applications with Freescale microcontrollers at the following link:
If you have troubles regarding the connection of a Composite USB Device to a Windows PC, maybe this link could help you:
Hope this will be useful for you.
Unfortunately, if you have taken the time to read the USBUG app. K, you would have realized that it is only the "plug it in the windows computer and install the driver" part that is mentioned there, not the "here is how to create a new project from A-to-Z with the Kinetis Usb stack 4.1.1 examples" nor the "here is how to take our projects and compiled them" part. I find this document only skims the surface of the problem (or solution) on how to build an application that uses composite usb devices. There is the USBAPIRM also available but only looks like an enumeration of all the header prototype's comments that one would find inside the code of the stack. I find it really hard to get by the firsts steps on how to go bare metal and use the examples properly. So here is my question:
Are they any tutorials that takes us step by step and shows how to use and implement the usb stack and their examples? (other then the so-called documents given by a generic search of application notes on freescale website that is...)
Since this took me a little while to figure out, maybe this will help someone else. The USB and CDC composite example mentioned in Appendix K of USBUG.pdf is actually part of the USB Stack v4.1.1 release. However, it is NOT a Processor Expert project so it will not be in the Processor Expert\Examples folder like you might expect. If you installed with the defaults on Windows, you should be able to find the project folders for many different micros in the following folder:
C:\Freescale\Freescale USB Stack v4.1.1\Source\Device\app_composite\msd_and_cdc\cw10
I opened this in CW 10.6 for the KL25Z (kinetis_l2k folder) and it built without errors, although I did not try to verify any functionality.
Bump to see if anyone has had success. I would like to port the example to a k20 device. But, adding the k20 header to the example project "Device\app_composite\msd_and_cdc" throws errors.
It would be very helpful if freescale to could at least put together a quick start that actually shows how to take the examples to new processors.
Hello M J,
I did manage to get something compiling but I wasn't able to confirm if it really worked and haven't try to tinker with it since then. Here is what I did and pardon me if some details are missing, I can't exactly remember all I did at that time. First thing I did is find a working example in the non composite directory, mainly the CDC example alone, for my specific k20 processor. Most of the files specific to the k20 I am using are available in the single application example tree. I created a new folder in the composite example folder for the new configuration, and copied all the files from another configuration from the same example ( Lets say I use the MK20DX256VLH5 (or K20_72) and theres a working example for the K40 something, I copied the K40 example in a new folder and named it K20_72 inside the composite app folder (sorry I can't recall all the folder names, I dont have that project in front of me now)) then went to a lot of trouble to make it a real MK20_72 project. In retrospect, my project skills were not that good at that time I was just starting to use CodeWarrior IDE and I think I could just have created a new project inside the example structure but what I did "worked" even if its was really long. I openned all the project configuration files in a text editor and "search and replace" all keywords regarding the original processor name with the new processor name to be use (or any other keywords regarding the original processor project copied). Also, I need to change the project files name accordingly with the new folder name and new used processor. After opening the new "hacked and sewn back togheter" project, I think I didn't have any errors from opening it, after closing it and "manually" editing it in a text editor many times. When I wasn't sure of the correct syntax to use in the new project I wanted to create, I refered to the project with the same processor I wanted to use in the simple app folder examples. At this point, I am in doubt if I didn't use the single app project configuration files, and changed the "include directories" in the project settings, but I think it's something that could of been done too. I remember something with the "derivative.h" or "mk20dx72.h" (can't remember the specific name) which I had to replace with the one I wanted to use, also copying the linker memory map file and linker script file (.lcf) for the right processor, and adding some files in the composite common folder from the single app common folder (think it's the usb stack files for the kinetis series that are more generic in the single app examples folder).I think I just opened, compiled and cleared all the errors until I had all the files needed, include and defines right. I can give you more information and maybe include the project I created but I cannot do that now, it will be later this week.
Hopes this helps, best regards,
Thanks for you input. It would be very useful if you could upload your project for comparison. Maybe freescale can chime in on steps for porting the current USB example projects to alternative processors. It seems to a be very non-trivial task at the moment. I have gone through the 4.1.1 documentation and gotten started on the process of getting the examples working then porting to alternate kinetis variants. Note that the "USBUG.pdf" and the "USBAPIRM.pdf" do not contain nearly enough information on setting up your own USB projects. Section 5 was somewhat useful, but lacking in many many details.
Some notes and some questions on my progress in case it is useful to anyone:
What has made it even more confusing is that the codewarrior example projects with library version 22.214.171.124 are using dfferent startup code and vector tables than those generated by the codewarrior wizard. I am grateful that they are there and they do build though. Can someone explain why they are using the vectors.c for the interrupt code rather than the kinetis_sysinit.c vector source? This would be helpful in being able to port the USB source to a standard codewarrior created project.
I am currently working with some of the examples and have managed to get a couple working with the freedom KL25Z (labeled cw10\kinetis_l2k in the directory structure)boards. I am again grateful that I can get them to run on the low cost freedom boards, but they were built for the tower board variant. This causes the MSD to hard fault, but it does build, which gives me hope for porting it. I am not sure if the example is using external flash that may be causing it to hard fault on freedom board.
Also, CDC examples runs fine, but the composite example with MSD has the same issue as above. The MSD is supposed to mount and contain the *.inf driver setup file, but where it does the MSD does not mount I cannot access the file and the CDC usb setup is different from that of the standalone CDC example. I tried to change the VID,PID of the composite descriptor to match that of the standalone CDC drive *.ini file, but got the bluescreen of death (woops). I tried to copy the contents of the "inf_file.c" that contains all of the inf data with line feeds, etc, - removed line feeds and tried to use install the dirvers, but failed.
I Need to learn more about how to properly configure the descriptors a composite device. Can someone explain where I can information on how to setup the descriptors for a composite device? I see that there is a "usb_composite.c\h" but they are not documented in the "USBUG.pdf" or the "USBAPIRM.pdf". I have usb_composite.c/h, but it is unclear to me how these link the descriptors and USB functionality together. Can anyone give further information or references to further material in this regard?
Im sorry I can't bet a better help right now, the usb stack is a mystery to me right now too. As for my project, I would have to copy all the stack source files too, as they are all needed to compile the project. One approach I didn't try but is widely used for ProcessorExpert projects (well I do when I have to re-create one for another board or processor) is to have a working project openned side-by-side with a new project and just reproduce everything in the new one, using the working one as a reference. One place you want to spend most of the time is in the "Project Settings" and just go tab after tab to make everything as close (or different if needs to be) as the original one. Thing is, as much as Freescale could give procedure and maybe training videos (wink wink freescale), your personnal skills will only be as great as the time you have spent howning them.I guess its all about repitition, failing and then succeeding. I know this is frustrating at first but trust me, keep trying and you will succeed. So if you got a working project for the TWR board, try to find the schematics of that board and compare it to the one you got, and yeah maybe the flash makes a difference. Usually a USB MSD device (not host) has some memory to share, as in space to put the files in. If your FRDM doesn't have some sort of storage, the FAT section wont be able to mount anything (drive or disk space) but I guess it could be mapped to the internal flash or ram (if a couple of kb or 1 mo can do something for you). My grand plan was to use a SD card but then you'd have to figure how the fat can be rigged to it, and I haven't gone that far yet. One thing I'd recomand you is to start some ProcessorExpert projects and look into the project structures it creates. Also, if you want some real hands-on experience, you can try this marvellous website http://mcuoneclipse.com/ where you can feel free to ask any question and use the working examples as a good start point.
Hope this helps you,
Retrieving data ...