Debugger explodes on GPIO write

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

Debugger explodes on GPIO write

773 Views
dbwolfe
Contributor III

I'm trying to debug a program I wrote for an MKL26Z MCU.  The MCU is on a custom PCB, in the CAL4 WLSCP package.  Debugging is happening using SWD, with SWDIO, SWCLK and reset connected.  SWDIO is pulled up with a 10K, clock is pulled down with a 10K, and the reset pin is pulled up with a 10K and a cap to ground, as recommended.  I am using a Segger Base debugger, and KDS 3.2.

During the startup process, I set some GPIO to enable or disable various supplies/clocks/peripherals etc.  On the first call of the GPIO_DRV_WritePinOutput() function (KSDK 1.3), the debugger freaks out and halts execution.  I attached screenshots showing the behavior, before and after I step the line that causes the problem (before/after.png).  Stepping into the function, the most granular instruction I can find related to the error is GPIO_WR_PSOR, which is just a macro to write the PSOR register for a GPIO pin.

In my main, the processor expert init function is being called before the GPIO write, and I have configured GPIO for auto-initialization in PE.  There are no interrupts on the pin.  Interestingly, the problem does not appear to be specific to that particular function call.  If I comment out the first GPIO write function call, the debugger fails on the next call.  However, the problem is definitely related to that code - if I comment out the function in which the GPIO write is being called, I can debug and the program executes as expected.

Interestingly, if I close the debugger session after the device has been flashed, my program executes correctly.  It has a UART command line interface, and I can send commands, receive responses, and observe correct peripheral behavior.  The problem seems to be isolated to debugging the unit.

Anyone have an idea about what is happening here?

0 Kudos
1 Reply

627 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Devin Wolfe

First of all, we highly recommend our customers using the last version of SDK (v2.x), there are too many differences between version 1.x and 2.x but it is the best option for a new application.

Regarding your issue, I couldn't reproduce it, are you able to flash and debug one of the examples codes that we provided with the software package? I would like to check if this is a board related problem.

Best regards

Jorge Alcala

0 Kudos