bit manipulation engine in KL

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

bit manipulation engine in KL

2,198件の閲覧回数
stefanomanca
Contributor III

Hi, I'm wondering if I can use BME to know the state of a pin of a port but without to modify the value.

 

ex:

 

if((GPIOC_PDIR & 0x40)){...

..

}

 

Thank you.

ラベル(1)
0 件の賞賛
返信
3 返答(返信)

939件の閲覧回数
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Stefano:

What do you mean about reading without modifying?

When you read the GPIOx_PDIR register, the values remain, they are not mofidied. Or could you explain a little more please?.

Regards!

Jorge Gonzalez

0 件の賞賛
返信

939件の閲覧回数
stefanomanca
Contributor III

Hi Jorge, to know the level of ptc6 I need to do (GPIOC_PDIR & 0x40) that is an AND-bit operation. I wonder if I can avoid to do this operation by BME getting the value of ptc6 immediatelly.

Thank you.

0 件の賞賛
返信

939件の閲覧回数
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Stefano:

I had this answer pending for you. I searched and found that it is possible to read one or more bits of a determined peripheral with BME. In fact, there are some example source codes in the KL25_SC package. I guess you have it, but in any case here is the link:

FRDM-KL25Z: Freescale Freedom Development Platform for Kinetis KL14/15/24/25 MCUs

There is a header file called "bme,h" which contains macros with the bit manipulation functions. For the case you mentioned, the reading of the bit would be something like this:

rdata = BME_UBFX_W(&GPIOC_PDIR, 0x6, 0x1);     // rdata is the variable in which you store the PTC6 value

I am also attaching a presentation with more info regarding BME.

Regards!

Jorge Gonzalez

0 件の賞賛
返信