KW47: Using GPIO Port D

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

KW47: Using GPIO Port D

651 Views
alanlow
Contributor II

Hi,

I realized that there is no definition of kCLOCK_GpioD and kCOCK_PortD in the fsl_clock.h.

Is there any sample code to initialize Port D for KW47?

 

Thanks.

0 Kudos
Reply
4 Replies

617 Views
sofiaurueta
NXP Employee
NXP Employee

Hello, 
Hope you are doing well. 

 

There is an example in the SDK that uses PTD1. You could use that implementation as a reference for configuring the PORT D GPIO. 

Although using Config Tools with wireless examples is not recommended as it may modify required configurations, you can create a blank project to generate the code that enables the port using Config Tools and then manually copy that code into your existing project. 

 

Best regards, 
Ana Sofia. 

0 Kudos
Reply

613 Views
alanlow
Contributor II
Hi Sofia,

Thanks for your quick response. May I know which example you are reference?

Thanks!
0 Kudos
Reply

579 Views
sofiaurueta
NXP Employee
NXP Employee

Hello,

The implementation is included in the SDK, please see in pin_mux.c file, the function BOARD_InitPinButton0 which configures the pin routing for PTD1, as well as defines for GPIOD, PORTD in pin_mux.h file.

 

Best regards,
Ana Sofia.

0 Kudos
Reply

632 Views
tejoka5968
Contributor I

Hello!

On KW47, there are no kCLOCK_GpioD or kCLOCK_PortD definitions in fsl_clock.h because Port D isn’t part of the KW47 clock tree. Only ports A, B, C, and E are supported. To initialize a port, enable its clock with CLOCK_EnableClock(kCLOCK_PortX), set the pin mux using PORT_SetPinMux(), and then configure the GPIO with GPIO_PinInit(). For reference, check the KW47 SDK GPIO demos (like LED toggle) which show the correct initialization flow. 

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2321059%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EKW47%3A%20Using%20GPIO%20Port%20D%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2321059%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EI%20realized%20that%20there%20is%20no%20definition%20of%20kCLOCK_GpioD%20and%20kCOCK_PortD%20in%20the%20fsl_clock.h.%3C%2FP%3E%3CP%3EIs%20there%20any%20sample%20code%20to%20initialize%20Port%20D%20for%20KW47%3F%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EThanks.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2322126%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20KW47%3A%20Using%20GPIO%20Port%20D%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2322126%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%3C%2FP%3E%0A%3CP%3EThe%20implementation%20is%20included%20in%20the%20SDK%2C%20please%20see%20in%20pin_mux.c%20file%2C%20the%20function%20BOARD_InitPinButton0%20which%20configures%20the%20pin%20routing%20for%20PTD1%2C%20as%20well%20as%20defines%20for%20GPIOD%2C%20PORTD%20in%20pin_mux.h%20file.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EBest%20regards%2C%3CBR%20%2F%3EAna%20Sofia.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2321574%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20KW47%3A%20Using%20GPIO%20Port%20D%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2321574%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EHi%20Sofia%2C%3CBR%20%2F%3E%3CBR%20%2F%3EThanks%20for%20your%20quick%20response.%20May%20I%20know%20which%20example%20you%20are%20reference%3F%3CBR%20%2F%3E%3CBR%20%2F%3EThanks!%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2321537%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20KW47%3A%20Using%20GPIO%20Port%20D%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2321537%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%26nbsp%3B%3CBR%20%2F%3EHope%20you%20are%20doing%20well.%26nbsp%3B%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EThere%20is%20an%20example%20in%20the%20SDK%20that%20uses%26nbsp%3BPTD1.%20You%20could%20use%20that%20implementation%20as%20a%20reference%20for%20configuring%20the%26nbsp%3BPORT%20D%20GPIO.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAlthough%20using%20Config%20Tools%20with%20wireless%20examples%20is%20not%20recommended%20as%20it%20may%20modify%20required%20configurations%2C%20you%20can%20create%20a%20blank%20project%20to%20generate%20the%20code%20that%20enables%20the%20port%20using%20Config%20Tools%20and%20then%20manually%20copy%20that%20code%20into%20your%20existing%20project.%26nbsp%3B%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EBest%20regards%2C%26nbsp%3B%3CBR%20%2F%3EAna%20Sofia.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2321095%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20KW47%3A%20Using%20GPIO%20Port%20D%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2321095%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello!%3C%2FP%3E%3CP%3EOn%20KW47%2C%20there%20are%20no%20kCLOCK_GpioD%20or%20kCLOCK_PortD%20definitions%20in%20fsl_clock.h%20because%20Port%20D%20isn%E2%80%99t%20part%20of%20the%20KW47%20clock%20tree.%20Only%20ports%20A%2C%20B%2C%20C%2C%20and%20E%20are%20supported.%20To%20initialize%20a%20port%2C%20enable%20its%20clock%20with%20CLOCK_EnableClock(kCLOCK_PortX)%2C%20set%20the%20pin%20mux%20using%20PORT_SetPinMux()%2C%20and%20then%20configure%20the%20GPIO%20with%20GPIO_PinInit().%20For%20reference%2C%20check%20the%20KW47%20SDK%20GPIO%20demos%20(like%20LED%20toggle)%20which%20show%20the%20correct%20initialization%20flow.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E