Getting the pin status using PINS_DRV_ReadPins

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Getting the pin status using PINS_DRV_ReadPins

15,454 次查看
abhinandan
Contributor II

Hi Community,

  I am working on S32K118 eval board, I need to get the status of each pin, can you please help me to know whether I can get this using PINS_DRV_Readpins command and how to obtain the output.

 

Thank You 

0 项奖励
回复
26 回复数

13,718 次查看
abhinandan
Contributor II

Hi Community,

   I want to read the status of each pins of every port, I used  PINS_DRV_READPINS function, but I am not getting the required result, can you please help me with this. I am attaching the part of the code as reference, kindly let me know where I am getting it wrong. I want to print the value of the returned by this function on the console.

 

Thank You

0 项奖励
回复

13,676 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Are you able to read the state of a pin in the last reply?

May I ask if the problem you are encountering now is that PINS_DRV_READPINS cannot read the correct value, or the correct value cannot be send out through LPUART?

0 项奖励
回复

13,665 次查看
abhinandan
Contributor II

Hi Robin,

   Thank you for your reply, I am unable to read out the value through LPUART, is there a way to get that value displayed through UART. Kindly let me know about this. I had attached the code I m using to read the value, please let me know whether it is the proper method.

 

0 项奖励
回复

13,657 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

If the PINS_DRV_ReadPins able to get the correct status of PORT, and the issue is iota can not convert to decimal. Then would you please submit a new question in S32 Design Studio, maybe IDE experts can help you solve the iota problem.

0 项奖励
回复

13,656 次查看
abhinandan
Contributor II

Hi Robin,

  Thank you for your reply, will post it there.

0 项奖励
回复

14,230 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi abhinandan,

Although the description of PINS_DRV_ReadPins shows: This function returns the current input values from a port. Only pins configured as input will have meaningful values.

But I think you can still read the pin state via the GPIO port data input register (GPIO_PDIR).

pin state to be read via the corresponding GPIO Port Data.png

Best Regards,
Robin
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 项奖励
回复

14,142 次查看
abhinandan
Contributor II

Hi Robin,

  Thank You for your reply, will check this.

0 项奖励
回复

14,207 次查看
AVND
Contributor I

Hi Robin,

           PINS_DRV_ReadPins function always return 1 for corresponding GPIO pin which is configured as input or else always return 0 if configured as output. Is this correct? For input configuration it didn't  change the pin value to zero for short circuiting the configured pin with Ground.

0 项奖励
回复

14,191 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

How about direct read the value of GPIO_PDIR?
When pin is configured as input with internal pull down enabled, then test PINS_DRV_ReadPins.
When pin is configured as output and output high or low, then test PINS_DRV_ReadPins.

14,184 次查看
AVND
Contributor I

yes PIN_DRV_ReadPins function return the GPIO_PDIR value,

this is how i have read the PTC8 pin status

//Reading the input value of PTC8:

uint32_t pinstatus = PINS_DRV_ReadPins(GPIOC_PORT) >> (PTC8_INPUT) & 0x01;

 

0 项奖励
回复

14,183 次查看
AVND
Contributor I

PIN_read.png

0 项奖励
回复

14,181 次查看
AVND
Contributor I

Hi Robin,

This is what i want to works like push button configuration,

1.Initially PTC8 pin is in zero state value
2.When interrupt came(e.g.,PTC8 pin connecting with VCC) the value become 1.
3.When PTC8 pin connecting with GND then the value become 0.PIN_read2.png

0 项奖励
回复

14,164 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Configure PTC8 as output, and able to see the PDIR change with toggle.

Pins Tool PTC8 output.pngtoggle PTC8 PDIR.pngtoggle PTC8 PDIR(1).png

Why you configure PTC8 as input but call PINS_DRV_SetPins and PINS_DRV_ClearPins.

0 项奖励
回复

14,151 次查看
AVND
Contributor I

No, i am calling PINS_DRV_SetPins and PINS_DRV_ClearPins for LED pin not for PTC8 pin

 

pinreadandclear.png

0 项奖励
回复

14,140 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

So you just want the external voltage connect to PTC8, and trigger PORT interrupt, then output value to other pins?

In short, you want to implement the PTC8 pin interrupt and control the output level of other pins in the pin interrupt?

Please refer the button interrupt in can_pal_s32k118 example:

can_pal_s32k118.pngbutton interrupt.png

 

0 项奖励
回复

14,129 次查看
AVND
Contributor I

Hi Robin,

           Yeah this button interrupt (can_pal) code does what i need, but when i configured PTC8 pin instead of both button pin PTD3 and PTD5,interrupt is not triggered what will be the problem? Do you have any idea?

0 项奖励
回复

14,123 次查看
AVND
Contributor I

Even i configured PTD2 pin for interrupt it works fine like button pins, but PTC8 pin not get triggered.why its not get triggered?

 

0 项奖励
回复

14,069 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

S32K118EVB Q064 or S32K118EVB2Q048 are you using?
The R683 is DNP, so the signal did not route to PORTC 8 by default.

PTC8 R683 DNP S32K118EVB2Q048.png

I am able to trigger PORTC 8 interrupt, test on S32K118EVB.

PORTC8 interrupt rising edge.png

0 项奖励
回复

14,063 次查看
AVND
Contributor I

Then how did you get the interrupt for PTC8?

0 项奖励
回复

14,064 次查看
AVND
Contributor I

I am using S32K118EVB2Q048,

so because of  R683 is DNP, i cannot able to get the interrupt for the pin?

0 项奖励
回复