Hi Rahul,
I'd like to highly recommend that you should choose USB On-The-Go mode which can determine the role of the device based on hardware signal,
and then initializes the device in the appropriate mode of operation (host or peripheral) based on how it is connected.
The KSDK 1.2 also contains the USB On-The-Go demo for K21 and please go ahead to download through the link as below.
Software Development Kit for Kinetis MCUs|Freescale
Have a great day,
Ping
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------