NXP Kinetis K22 USB Issues When Using USB Stack In C++

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

NXP Kinetis K22 USB Issues When Using USB Stack In C++

458 Views
prabhutravels
Contributor I

Does anyone have any experience when using the NXP/Freescale C USB Stack in C++?

I'm facing a issue whereby when the CDC device attempts to enumerate, the device descriptor requests are failing. I've debugged as far as I can and I can see that the USB OTG interrupt is being entered for SLEEP, RESET and SOF states but no others.

What I'm assuming is that I've missed something subtle however in the grand scheme of things, the only thing I've really changed is adding an `extern "C"` to the USB ISR function. Clocking is correct, interrupts have been configured and enabled.

I have an existing C project which works absolutely fine, using the same USB stack source code. This is what I'm moving over from.

My target hardware is a Kinetis MK22FN1M0AVLH12 device, running from a 16MHz crystal.

I've not posted any code as I don't really know what to post at the moment - I can post anything which would be relevant.

Labels (1)
0 Kudos
Reply
2 Replies

333 Views
prabhutravels
Contributor I
Does anyone have any experience when using the NXP/Freescale C USB Stack in C++?

I'm facing a issue whereby when the CDC device attempts to enumerate, the device descriptor requests are failing. I've debugged as far as I can and I can see that the USB OTG interrupt is being entered for SLEEP, RESET and SOF states but no others.

What I'm assuming is that I've missed something subtle however in the grand scheme of things, the only thing I've really changed is adding an `extern "C"` to the USB ISR function. Clocking is correct, interrupts have been configured and enabled.

I have an existing C project which works absolutely fine, using the same USB stack source code. This is what I'm moving over from.

My target hardware is a Kinetis MK22FN1M0AVLH12 device, running from a 16MHz crystal.

I've not posted any code as I don't really know what to post at the moment - I can post anything which would be relevant. https://routerlogin.uno/

I got this,...
0 Kudos
Reply

361 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @prabhutravels 

  • Please verify that extern "C" is added to the correct ISR function. Also add a GPIO toggle inside the ISR to confirm whether the interrupt is actually entered.

  • Try moving your USB-related C++ source file back to a pure C file and test again. If the device enumerates successfully, it indicates that the issue is related to the C++ environment.

 

BR

Alice

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2340286%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ENXP%20Kinetis%20K22%20USB%20Issues%20When%20Using%20USB%20Stack%20In%20C%2B%2B%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2340286%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EDoes%20anyone%20have%20any%20experience%20when%20using%20the%20NXP%2FFreescale%20C%20USB%20Stack%20in%20C%2B%2B%3F%3C%2FP%3E%3CP%3EI'm%20facing%20a%20issue%20whereby%20when%20the%20CDC%20device%20attempts%20to%20enumerate%2C%20the%20device%20descriptor%20requests%20are%20failing.%20I've%20debugged%20as%20far%20as%20I%20can%20and%20I%20can%20see%20that%20the%20USB%20OTG%20interrupt%20is%20being%20entered%20for%20SLEEP%2C%20RESET%20and%20SOF%20states%20but%20no%20others.%3C%2FP%3E%3CP%3EWhat%20I'm%20assuming%20is%20that%20I've%20missed%20something%20subtle%20however%20in%20the%20grand%20scheme%20of%20things%2C%20the%20only%20thing%20I've%20really%20changed%20is%20adding%20an%20%60extern%20%22C%22%60%20to%20the%20USB%20ISR%20function.%20Clocking%20is%20correct%2C%20interrupts%20have%20been%20configured%20and%20enabled.%3C%2FP%3E%3CP%3EI%20have%20an%20existing%20C%20project%20which%20works%20absolutely%20fine%2C%20using%20the%20same%20USB%20stack%20source%20code.%20This%20is%20what%20I'm%20moving%20over%20from.%3C%2FP%3E%3CP%3EMy%20target%20hardware%20is%20a%20Kinetis%20MK22FN1M0AVLH12%20device%2C%20running%20from%20a%2016MHz%20crystal.%3C%2FP%3E%3CP%3EI've%20not%20posted%20any%20code%20as%20I%20don't%20really%20know%20what%20to%20post%20at%20the%20moment%20-%20I%20can%20post%20anything%20which%20would%20be%20relevant.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2340286%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3EKinetis%20K%20Series%20MCUs%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2341994%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20NXP%20Kinetis%20K22%20USB%20Issues%20When%20Using%20USB%20Stack%20In%20C%2B%2B%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2341994%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F261061%22%20target%3D%22_blank%22%3E%40prabhutravels%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%0A%3CUL%3E%0A%3CLI%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%20color%3D%22%23000000%22%3EPlease%20verify%20that%20%3CCODE%3Eextern%20%22C%22%3C%2FCODE%3E%20is%20added%20to%20the%20correct%20ISR%20function.%20Also%20add%20a%20GPIO%20toggle%20inside%20the%20ISR%20to%20confirm%20whether%20the%20interrupt%20is%20actually%20entered.%3C%2FFONT%3E%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%20color%3D%22%23000000%22%3ETry%20moving%20your%20USB-related%20C%2B%2B%20source%20file%20back%20to%20a%20pure%20C%20file%20and%20test%20again.%20If%20the%20device%20enumerates%20successfully%2C%20it%20indicates%20that%20the%20issue%20is%20related%20to%20the%20C%2B%2B%20environment.%3C%2FFONT%3E%3C%2FP%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CBR%20%2F%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%20color%3D%22%23000000%22%3EBR%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%20color%3D%22%23000000%22%3EAlice%3C%2FFONT%3E%3C%2FP%3E%0A%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2343076%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20NXP%20Kinetis%20K22%20USB%20Issues%20When%20Using%20USB%20Stack%20In%20C%2B%2B%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2343076%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EDoes%20anyone%20have%20any%20experience%20when%20using%20the%20NXP%2FFreescale%20C%20USB%20Stack%20in%20C%2B%2B%3F%3CBR%20%2F%3E%3CBR%20%2F%3EI'm%20facing%20a%20issue%20whereby%20when%20the%20CDC%20device%20attempts%20to%20enumerate%2C%20the%20device%20descriptor%20requests%20are%20failing.%20I've%20debugged%20as%20far%20as%20I%20can%20and%20I%20can%20see%20that%20the%20USB%20OTG%20interrupt%20is%20being%20entered%20for%20SLEEP%2C%20RESET%20and%20SOF%20states%20but%20no%20others.%3CBR%20%2F%3E%3CBR%20%2F%3EWhat%20I'm%20assuming%20is%20that%20I've%20missed%20something%20subtle%20however%20in%20the%20grand%20scheme%20of%20things%2C%20the%20only%20thing%20I've%20really%20changed%20is%20adding%20an%20%60extern%20%22C%22%60%20to%20the%20USB%20ISR%20function.%20Clocking%20is%20correct%2C%20interrupts%20have%20been%20configured%20and%20enabled.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20have%20an%20existing%20C%20project%20which%20works%20absolutely%20fine%2C%20using%20the%20same%20USB%20stack%20source%20code.%20This%20is%20what%20I'm%20moving%20over%20from.%3CBR%20%2F%3E%3CBR%20%2F%3EMy%20target%20hardware%20is%20a%20Kinetis%20MK22FN1M0AVLH12%20device%2C%20running%20from%20a%2016MHz%20crystal.%3CBR%20%2F%3E%3CBR%20%2F%3EI've%20not%20posted%20any%20code%20as%20I%20don't%20really%20know%20what%20to%20post%20at%20the%20moment%20-%20I%20can%20post%20anything%20which%20would%20be%20relevant.%20%3CA%20href%3D%22https%3A%2F%2Frouterlogin.uno%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Frouterlogin.uno%2F%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3EI%20got%20this%2C...%3C%2FLINGO-BODY%3E