[MCXN236] Example source code for OTG

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

[MCXN236] Example source code for OTG

334 Views
bryan_hong
Senior Contributor I

dear nxp 

Could you provide the example  source code for OTG on mcxn236 ?

I can't find the example `application code hub` and MCUXpresso.

Thanks,
Bryan

Labels (1)
Tags (1)
0 Kudos
Reply
1 Reply

306 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @bryan_hong 

Thank you for your question.

The OTG protocol is quite complex and has largely been phased out. Using a pin to detect and switch between host and device  is a simpler approach.

Please refer to the pin_detect_hid_mouse demo under SDK  for reference. 

Alice_Yang_0-1763005755267.png

 

When running the demo,

Host:  

Plug in a mouse to the test board. The board acts as an USB host. The stack switches to host mode and some device attached information is printed out.

Device:

Unplug the mouse with the cable. The board now acts as a USB device mouse. The mouse is detached and the USB switches to the device mode information.

 

Hope it helps.

 

BR

Alice

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2203966%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%5BMCXN236%5D%20Example%20source%20code%20for%20OTG%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2203966%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3Edear%20nxp%26nbsp%3B%3C%2FP%3E%3CP%3ECould%20you%20provide%20the%20example%26nbsp%3B%20source%20code%20for%20OTG%20on%20mcxn236%20%3F%3C%2FP%3E%3CP%3EI%20can't%20find%20the%20example%20%60application%20code%20hub%60%20and%20MCUXpresso.%3C%2FP%3E%3CP%3EThanks%2C%3CBR%20%2F%3EBryan%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2203966%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3EUSB%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2204082%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20%5BMCXN236%5D%20Example%20source%20code%20for%20OTG%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2204082%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%2F107445%22%20target%3D%22_blank%22%3E%40bryan_hong%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThank%20you%20for%20your%20question.%3C%2FP%3E%0A%3CP%3EThe%20OTG%20protocol%20is%20quite%20complex%20and%20has%20largely%20been%20phased%20out.%20Using%20a%20pin%20to%20detect%20and%20switch%20between%20host%20and%20device%26nbsp%3B%20is%20a%20simpler%20approach.%3C%2FP%3E%0A%3CP%3EPlease%20refer%20to%20the%20%3CCODE%3Epin_detect_hid_mouse%3C%2FCODE%3E%20demo%20under%20SDK%26nbsp%3B%20for%20reference.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Alice_Yang_0-1763005755267.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Alice_Yang_0-1763005755267.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F365410iC2B3E1FFF1C6FEBC%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Alice_Yang_0-1763005755267.png%22%20alt%3D%22Alice_Yang_0-1763005755267.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EWhen%20running%20the%20demo%2C%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EHost%3A%26nbsp%3B%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EPlug%20in%20a%20mouse%20to%20the%20test%20board.%20The%20board%20acts%20as%20an%20USB%20host.%20The%20stack%20switches%20to%3CSTRONG%3E%20host%20mode%3C%2FSTRONG%3E%20and%20some%20device%20attached%20information%20is%20printed%20out.%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EDevice%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EUnplug%20the%20mouse%20with%20the%20cable.%20The%20board%20now%20acts%20as%20a%20USB%20device%20mouse.%20The%20mouse%20is%20detached%20and%20the%20USB%20switches%20to%20the%3CSTRONG%3E%20device%20mode%3C%2FSTRONG%3E%20information.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EHope%20it%20helps.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EBR%3C%2FP%3E%0A%3CP%3EAlice%3C%2FP%3E%3C%2FLINGO-BODY%3E