Hi Tushar,
Do you use evaluation boar or your own? If you use your own, please send me schematic for a short review.
Did you disconnect BDM interface when you reset/restart MCU? The BDM interface (debugger) may try reconnecting to MCU. Since BKGD pin’s voltage level is tested during reset, it may lead to reset into the special mode where MCU waits for BDM commands.
What means “at the very start of main”? Is there any code prior that simple I/O toggle commands (for example for clock configuration)? The clock configuration code may contain loop for waiting on PLL LOCK status. Incorrect clock parameters may lead to the situation where PLL cannot lock at target frequency = endless loop.
Do you use bare metal CW project or you use any initialization tool like ProcessorExpert?
The typical issue when code works in special mode (during debugging) and it does not work in normal mode is in writing into specific registers (or specific bits) which cannot be written in normal mode (like TCNT) or could be written just once (like MODRRx, ECLKCTL, CPMUCOP, CPMUVREGCTL,..).
I hope it helps you.
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------