Hi Anders,
Please refer to the FRDM-K20D50M sample code, the frdm-k20d50m-demo have the function what you needed:
http://cache.nxp.com/files/32bit/software/KINETIS_50MHZ_SC.zip?fpsp=1&WT_TYPE=Lab%20and%20Test%20Sof...
You can find the project in folder:\kinetis_50MHz_sc\k20d50m_sc_baremetal\build\iar\frdm-k20d50m-demo
Wish it helps you!
If you still have question, please let me know.
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------