Hello Again,
Now I have answer to what happened in my case.
1. The port configuration in my case did not contain the JTAG configuration. It is a must that you add these Pin configuration either manually or automatically when Port module is added to your configuration in EB Tresos (See under Default Recommended Configurations -> select PortRecConfiguration_JtagPins and add Port module). This was the main reason for the JTAG/SWD debug connection failure and not the watchdog.
2. The NotUsedPortPin was configured as IN.
3. In absence of the above code snippet for disabling watchdog, the function Port_Port_Ci_Init_UnusedPins() (called from Port_Port_Ci_Init()) never successfully completed because of watchdog resetting the system within 8ms.
4. After disabling the watchdog the Port_Port_Ci_Init_UnusedPins() changed all JTAG pins to IN configuration and it lost the connection to the debugger. In my case I am using the SWD mode for debug using the Open SDA interface (S32K148EVB).
To recover
1. Download Kinetis recovery utility from https://www.pemicro.com/login.cfm?from_url=http%3A%2F%2Fwww%2Epemicro%2Ecom%2Fdownloads%2Fdownload_f...
2. Make sure EVB is powered using 12V adapter and USB is connected to computer. All jumpers must be placed as per details in Quick start guide.
3. Launch the Kinetis utility, Select OpenSDAUSB under Test Hardware and SWD under communication. Click on Start.
4. Use should able to see the message "Continuously attempting to halt processor" and "Please try power cycling your board until this operation is sucessful" in the Kinetis utility console.
5. Remove the 12V adapter and reconnect. Now the message "Success. Process halted" is printed on the console. Close the Kinetis utility.
6. Reprogram the new software using NxpS32 Design Studio.
References:
1. Recovering Bricked Boards (FRDM, Reset, SWD and Low Power)
2. Bricking and Recovering FRDM-KL25Z Boards: Reset, SWD Clock and Low Power | MCU on Eclipse
Good luck,
Adithya M