how to configure some pins as input and some pins output of same port for FRDM-K82F ?

cancel
Showing results for 
Search instead for 
Did you mean: 

how to configure some pins as input and some pins output of same port for FRDM-K82F ?

481 Views
sandeepdwivedi
Contributor I

i am a beginner and trying to configure some pins as input and some pins output of same port of FRDM-K82F. but still i have learned only making output of pins but unable to make the input.

please tell me

5 Replies

315 Views
psjhawer
Contributor II

HI Sandeep,

I'm not sure about FRDM-K28F configuration setup, but every port in the MCU can be made as Input or Output or both. But you will have to configure that manually without help of processor expert. The details of making the will be available in the reference manual of ur microcontroller in Port Control And Interrupts chapter. I've made sample code for mk10dn64vlh5 configuring some pins as i/p and some as o/p of same port. Below is the snippet.:

void InitPorts(void)

{// enable port clock

    SIM_SCGC5 |=  1u << SIM_SCGC5_PORTA_SHIFT;

    SIM_SCGC5 |=  1u << SIM_SCGC5_PORTB_SHIFT;

    SIM_SCGC5 |=  1u << SIM_SCGC5_PORTC_SHIFT;

    SIM_SCGC5 |=  1u << SIM_SCGC5_PORTD_SHIFT;

    SIM_SCGC5 |=  1u << SIM_SCGC5_PORTE_SHIFT;

  PORTC_PCR0 = 0x00000140; //Output Pin

  PORTC_PCR1 = 0x00000140; //Output Pin

  PORTC_PCR2 = 0x00000140; //Output Pin

  PORTC_PCR3 = 0x00000140; //Output Pin

  PORTC_PCR4 = 0x00000140; //Output Pin

  PORTC_PCR5 = 0x00000143; //Input Pin

  PORTC_PCR6 = 0x00000143;//Input Pin

  PORTC_PCR7 = 0x00000143;//Input Pin

  PORTC_PCR8 = 0x00000143;//Input Pin

  PORTC_PCR9 = 0x00000143;//Input Pin

  PORTC_PCR10 = 0x00000143;//Input Pin

  PORTC_PCR11 = 0x00000143;//Input Pin

  GPIOC_PDDR = 0x0000001F; //Setting Direction of Pin(0 for input and 1 for output)

  GPIOC_PDOR = 0x00000000; //default output value on pins

}

Somthing similar has to be done in order to achieve your goal. Just refer to the above mentioned capter of the micronctroller and you'll be good to go.

I hope this helped.

Regards,

Prafful :smileyhappy:

0 Kudos

315 Views
psjhawer
Contributor II

Find all details in reference manual of the mcu MK82FN256VLL15 MCU in following link:

https://cache.nxp.com/files/32bit/doc/ref_manual/K82P121M150SF5RM.pdf

Page 246 Chapter 13 :smileywink:

0 Kudos

315 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Sandeep,

You can refer the gpio driver examples in SDK_2.0_FRDM-K82F. It can be download from Kinetis SDK Builder (REV 2 & 1.3).

gpio driver examples in SDK_2.0_FRDM-K82F.jpg

Please select the FRDM-K82F Configuration first, then build and download SDK_2.0_FRDM-K82F.

Select Configuration.jpg

Build and Download SDK Package.jpg

The Kinetis SDK v.2.0 API Reference Manual can be found in docs folder.

docs folder.jpg

Best Regards,

Robin

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

315 Views
sandeepdwivedi
Contributor I

Firstly Thanks for fast replying.

I have checked the examples GPIO> input interrupt

There is a variable g_ButtonPress, when ever we press Switch2 it changes i tried with new varible name g_ButtonPress3 so that we can detect press of switch3, but nothing happens,  in code also g_ButtonPress is once defined as bool and set to true and then later set to false , but how this is conncetd to switch2,  could ypu please tell me.

0 Kudos

315 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Sandeep,

The variable g_ButtonPress is conncetd to switch2 by BOARD_SW_IRQ_HANDLER().

You can refer the attached code to achieve using SW3 toggle LED_RED.

main.png

pin_mux board.png

Best Regards,

Robin

0 Kudos