Read the pin value of a configured peripheral

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

Read the pin value of a configured peripheral

694 Views
covejstewart
Contributor I

I am configuring the FRDM-K22F board with a Linear Tech LTC2449 ADC, which is connected via SPI.  The ADC signals that a conversion is complete by driving the MISO pin low when CS is toggled low.  In the example code from Linear, they drive the CS line low and then read the state of the MISO pin directly to determine if the End of Conversion(EOC) event has occurred.

I am new to Freescale / Kinetis Design Studio, and am trying to configure my project so that I can read the pin state (MISO) while that pin is being used by an SPI module.  I have attempted to use the BITIO Component configured as an Input, but it throws an error that says "Selected value is in conflict with another configuration property. . ."  What is the correct way to read the Pin value (PTC7) when that pin is allocated to an SPI component?

I have a sneaking suspicion that I am over-thinking this.

0 Kudos
1 Reply

468 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Jeffrey Stewart:

That is correct, BitIO and SPI components cannot share the pin. However adding a component just to read a pin value is probably an overkill. You can simply read directly the input data register, like below:

if(GPIOx_PDIR & (PIN_MASK))

{

...

}

Replace x with the port (A, B, C...) and PIN_MASK with the corresponding pin mask, e.g. (1 << 17) for PTA17.

I hope this helps.


Regards!,
Jorge Gonzalez

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

0 Kudos