LPC832: GPIO not working on default I2C and SWD pins

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

LPC832: GPIO not working on default I2C and SWD pins

ソリューションへジャンプ
1,251件の閲覧回数
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 件の賞賛
返信
1 解決策
1,218件の閲覧回数
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 件の賞賛
返信
3 返答(返信)
1,219件の閲覧回数
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 件の賞賛
返信
1,225件の閲覧回数
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 件の賞賛
返信
1,225件の閲覧回数
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 件の賞賛
返信