GPIO setting

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

GPIO setting

2,499 Views
darshandpatel
Contributor II

hi,

 I am using MKM34Z256VLL7 .In which  IIC using bit banging for giving SDA and SCL high-low i am using PDOR register directly to set that GPIO bit . Problem is total port F is getting disturbed other port pins are getting toggle in setting SDA , SCL with PDOR register if i  am setting and clearing with PSOR and PCOR respectively than this problem is not coming .

So, anyone can tell me the difference between direct use of PDOR and by PSOR .

Thank you.

Darshan

Tags (1)
5 Replies

2,138 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

From the GPIOx_PSOR register description, write 0 doesn't affect other bit status:

pastedImage_1.png

While, the GPIOx_PDOR register, write 0 will affect other bit status:

pastedImage_2.png

So, For example: if want to set PTF5 (I2C1_SCL), it need to use:

GPIOF_PDOR |= (0x1 << 5) ;

If want to clear PTF5 (I2C1_SCL), it need to use:

GPIOF_PDOR &=~(0x1 << 5);

Wish it helps.


Have a great day,
Ma Hui

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

2,138 Views
egoodii
Senior Contributor III

Or you can use the BME macros on GPIOF_PDOR to avoid the inefficient &= and |= ops for single bits in peripheral-address space.

2,138 Views
darshandpatel
Contributor II

And why that and,or ops giving such type of behavior.?

0 Kudos
Reply

2,137 Views
egoodii
Senior Contributor III

Sorry, I am not directly familiar with the byte-wide GPIO scheme in the KM series.  I agree, there is no 'obvious' reason that |= 'ones' and &= 'not ones' should fail, although I couldn't find a direct description as to whether reading GPIOF_PDOR would always return the exact contents of the output holding register, OR the pin state.

2,138 Views
darshandpatel
Contributor II

BME macro only useful , &= and |= ops giving undesired output.

0 Kudos
Reply