KL02 NMI pin assign issue

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

KL02 NMI pin assign issue

ソリューションへジャンプ
975件の閲覧回数
kriske
Contributor II

When I use below code to assign NMI pin to GPIO, it can't assign successful.

 

PORTB_PCR5 |= PORT_PCR_MUX(1);

 

174452_174452.png001.png

 

But If I use below code, it can assign successful.

PORTB_PCR5 = (uint32_t)((PORTB_PCR5 & (uint32_t)~(uint32_t)

                            ( PORT_PCR_ISF_MASK | PORT_PCR_MUX(0x06) ))

                            | (uint32_t)( PORT_PCR_MUX(0x01) ));

 

 

 

174454_174454.png002.png

 

 

Why I must need to clear PORT PCR ISF and set it to MUX 6 first and only in this way can the assign to GPIO(MUX 1) succeed.

 

ラベル(1)
タグ(3)
0 件の賞賛
1 解決策
810件の閲覧回数
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Kris,

The default data of PORTB_PCR5 ->MUX is 011 :

pastedImage_1.png

So if you simple use PORTB_PCR5 |= PORT_PCR_MUX(1);  the MUX still "011".

We need first clear it , then set it to "001".

Please pay attention that in your code, there is a  negation ,

pastedImage_2.png

(PORTB_PCR5 & (uint32_t)~(uint32_t)PORT_PCR_MUX(0x06))  this code is clear the [9:8] of PORTB_PCR5 .

In a word , if you do not care about the interrupt status flag, you can only use the below code to configure PTB5 to GPIO function :

 PORTB_PCR5 = (uint32_t)((PORTB_PCR5 & (uint32_t)~(uint32_t)( 
                PORT_PCR_MUX(0x06)
               )) | (uint32_t)(
                PORT_PCR_MUX(0x01)
                ));

Hope it helps


Have a great day,
Alice Yang

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

元の投稿で解決策を見る

0 件の賞賛
4 返答(返信)
810件の閲覧回数
kriske
Contributor II

Two questions are as follows,

 I want to confirm a GPIO read function, the PCR MUX is designated as other functions (such as I2C, TPM, UART), Then the GPIO's PDIR can also read the voltage of the pin?

The following example, The KL02 NMI pin must be cleared to 0 before setting to GPIO, So the question is we currently PTA4 MUX is set in the NMI, then I also use PDIR to read its potential?

Kris

0 件の賞賛
810件の閲覧回数
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Kris,

1. At the same time one pin only can configured as only one function. So i think the first question is no,

while you can make a simple code to have a test by yourself.

2. Sorry for i don't know clearly the second one, the most GPIO operate code is simple,

so i think you only need write a simple code,  you can get the answer by yourself .

BR

Alice

0 件の賞賛
810件の閲覧回数
kriske
Contributor II

Ok, I am finish test, If I assign it to digital peripheral module, it can detect voltage, but if I assign it to analog peripheral module, it don't any action.

0 件の賞賛
811件の閲覧回数
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Kris,

The default data of PORTB_PCR5 ->MUX is 011 :

pastedImage_1.png

So if you simple use PORTB_PCR5 |= PORT_PCR_MUX(1);  the MUX still "011".

We need first clear it , then set it to "001".

Please pay attention that in your code, there is a  negation ,

pastedImage_2.png

(PORTB_PCR5 & (uint32_t)~(uint32_t)PORT_PCR_MUX(0x06))  this code is clear the [9:8] of PORTB_PCR5 .

In a word , if you do not care about the interrupt status flag, you can only use the below code to configure PTB5 to GPIO function :

 PORTB_PCR5 = (uint32_t)((PORTB_PCR5 & (uint32_t)~(uint32_t)( 
                PORT_PCR_MUX(0x06)
               )) | (uint32_t)(
                PORT_PCR_MUX(0x01)
                ));

Hope it helps


Have a great day,
Alice Yang

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

0 件の賞賛