Global Pin Control Low Register

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

Global Pin Control Low Register

Jump to solution
1,171 Views
davidzhou
Contributor V

Hi,

I have K60 120M Tower. PORTB is configured as Alternative 2 as

  /* PORTB_PCR10: ISF=0,MUX=2 */

  PORTB_PCR10 = (uint32_t)((PORTB_PCR10 & (uint32_t)~(uint32_t)(

                 PORT_PCR_ISF_MASK |

                 PORT_PCR_MUX(0x05)

                )) | (uint32_t)(

                 PORT_PCR_MUX(0x02)

                ));

I have problem with toggling the PIN using Global Pin Control Low Register:

    PORTB_GPCLR = 0x4000400;    //(1<<26) | (1<<10);
   _time_delay(1);
   PORTB_GPCLR = 0x4000000;    //(1<<26) | (0<<10);

The pin is not toggling. Why?

If Pin is configured as GPIO, I can toggle it using gpio register.

Thank you,

David Zhou

0 Kudos
Reply
1 Solution
928 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi David,

    Yes, if you want to use the PTB10 as the SPIC CS function, you should configure it as the mux=2, and you don't need to control the GPIO, the SPI module will control the CS pin after you initialize the SPI module. If you want to control the GPIO pin, you must configure it as the GPIO function, not the SPI function.

Wish it help you!


Have a great day,

Jingjing

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

View solution in original post

0 Kudos
Reply
6 Replies
928 Views
davidzhou
Contributor V

What is the purpose to configure PTB10 as alternative 2?  I the pin is to be connected to external SPI CS, why can not configured as GPIO?

Thank you,

David Zhou

0 Kudos
Reply
928 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi David zhou,

    From the reference manual, you can get that, PTB10, mux=2 is SPI1_PCS0, it is the SPI cs function.

If you want to configure the PTB10 as the GPIO, you must choose MUX=1, this is the GPIO function.

Wish it helps you!

If you still have question, please contact me!


Have a great day,
Jingjing

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

0 Kudos
Reply
928 Views
davidzhou
Contributor V

Hi JingJing,

That's right. PTB10 , mux=2 is SPI1_PCS0. But I am confused a bit that how to control SPI1_PCS0? SPI1 in MCU is used as master, so how do I turn SPI1_PCS0 to low or high? I am using

PORTB_GPCLR = (1<<26) | (1<<10);

to set high and PORTB_GPCLR = (1<<26); to set to low. But the pin is not toggling. I don't know why.

Thank you,

David Zhou

0 Kudos
Reply
928 Views
davidzhou
Contributor V

Hi JingJing,

I figured out that if the pin is configured as PCS0, it is controlled by SPI driver.

Thank you,

David Zhou

0 Kudos
Reply
929 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi David,

    Yes, if you want to use the PTB10 as the SPIC CS function, you should configure it as the mux=2, and you don't need to control the GPIO, the SPI module will control the CS pin after you initialize the SPI module. If you want to control the GPIO pin, you must configure it as the GPIO function, not the SPI function.

Wish it help you!


Have a great day,

Jingjing

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

0 Kudos
Reply
928 Views
davidzhou
Contributor V

Thank you , JingJing

David Zhou

0 Kudos
Reply