4 years, 9 months ago.

FRDM-K64F PortIn / DigitalIn

Hello everyone,

Firstly, sorry for my bad english. I'm a french student and try to learn english as i can...

I'm new in mbed and started to work recently on the FRDM-K64F and today i'm stucked.

I have 8 GPIO on PTC0, PTC1, PTC2, PTC3, PTC4, PTC5, PTC7 and PTC8 (PTC6 is not on the board) and i want to read data as fast as the microcontroller can. Firstly, i tried to use code like this one to get my data :

... DigitalIn YOUT0(PTC0); DigitalIn YOUT1(PTC1); DigitalIn YOUT2(PTC2); DigitalIn YOUT3(PTC3); DigitalIn YOUT4(PTC4); DigitalIn YOUT5(PTC5); DigitalIn YOUT6(PTC7); DigitalIn YOUT7(PTC8); ... int value = YOUT0*1 + YOUT1*2 + YOUT2*4 + YOUT3*8 + YOUT4*16 + YOUT5*32+ YOUT6 * 64 + YOUT7 * 128 ; ...

It works well like that but i need to get data faster...

So I wanted to use PortIn. I tried this code :

PortIn portC(PortC, 0x000001BF);

...

int value = portC.read();

But it answers always 256 and i don't know why. When i use the mask : 0x000001F0 I get always 0.

Can someone help me ? Thank you guys ! :)

Be the first to answer this question.