bit manipulation engine in KL

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

bit manipulation engine in KL

1,905 Views
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.

Labels (1)
0 Kudos
3 Replies

646 Views
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 Kudos

646 Views
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 Kudos

646 Views
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 Kudos