LPC832: GPIO not working on default I2C and SWD pins

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

LPC832: GPIO not working on default I2C and SWD pins

Jump to solution
1,234 Views
aaronm
Contributor III

Hi!  I'm creating an X-Y matrix of LEDs and need a number of GPIO pins on an LPC832 (SOP20 package).  However, pins 7,8 (SWD), and 9,10 (I2C) do not want to comply with the GPIO configuration.  Pins 7 and 8 stay high, no matter how I set them, and pins 9 and 10 stay low.  I looked at

https://community.nxp.com/t5/LPC-Microcontrollers/LPC802-SWD-disabling/m-p/1572427

But it didn't help.  I've attached the compressed project so you can take a look for yourself.  It could be that I overlooked something, but the other GPIO pins seem to work as expected.

Thanks for any insight.

0 Kudos
Reply
1 Solution
1,201 Views
aaronm
Contributor III

Got it.  To disable SWD on the fixed pins, and enable GPIO on those pins, instead, I created this function and call it before BOARD_InitBootPins().  

Note, however, after you do this, SWD will not work as expected until you enable ISP mode.  To do that, connect pin 4 (PIO0_12) to ground, then touch pin 5 to ground and disconnect.  SWD should work again.

// near the other #includes
#include "fsl_swm.h"

// somewhere in your source code
void disableSWD ()
{
	CLOCK_EnableClock( kCLOCK_Swm );
	SWM_SetFixedPinSelect( SWM0, kSWM_SWCLK, false );
	SWM_SetFixedPinSelect( SWM0, kSWM_SWDIO, false );
	CLOCK_DisableClock( kCLOCK_Swm );
}

 

View solution in original post

0 Kudos
Reply
3 Replies
1,202 Views
aaronm
Contributor III

Got it.  To disable SWD on the fixed pins, and enable GPIO on those pins, instead, I created this function and call it before BOARD_InitBootPins().  

Note, however, after you do this, SWD will not work as expected until you enable ISP mode.  To do that, connect pin 4 (PIO0_12) to ground, then touch pin 5 to ground and disconnect.  SWD should work again.

// near the other #includes
#include "fsl_swm.h"

// somewhere in your source code
void disableSWD ()
{
	CLOCK_EnableClock( kCLOCK_Swm );
	SWM_SetFixedPinSelect( SWM0, kSWM_SWCLK, false );
	SWM_SetFixedPinSelect( SWM0, kSWM_SWDIO, false );
	CLOCK_DisableClock( kCLOCK_Swm );
}

 

0 Kudos
Reply
1,208 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @aaronm 

 

How about try to "After disabling the default SWD functions of pins,  pull-down the P0_4 to the low state prior to resetting the MCU, after that, release the P0_4.".

 

BR

Alice

0 Kudos
Reply
1,208 Views
aaronm
Contributor III

Ok, I understand the I2C pins - 9 & 10 - are open drain when in GPIO mode, so adding a pull-up resistor will allow the output to go high.  I've tested that and it works.

I'm still stuck on pins 7 & 8 - the SWD pins.  Do I have to disable SWD on chip startup?

0 Kudos
Reply