Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 6 months ago.
Port mask operation unclear from example
The PortIn example contains the following line:
PortIn p(Port2, 0x0000003F); p21-p26
I am afraid that I must be obtuse. I can't see how the "0x0000003F" mask relates to pins 21-26. I would think that "0x0000003F" would refer to pins 0-5. This, of course, assumes that pin 0 is, as typical, the least significant integer bit.
Can anyone shed some light on how the mask should be calculated?
Question relating to:
3 Answers
9 years, 6 months ago.
On the mbed LPC1768 pins 21 - 26 connect to LPC1768 Port 2 as follows:
pin 21 = Port 2 bit 5
pin 22 = Port 2 bit 4
pin 23 = Port 2 bit 3
pin 24 = Port 2 bit 2
pin 25 = Port 2 bit 1
pin 26 = Port 2 bit 0
The 6 least significant bits of Port 2 are used, hence the PortIn mask is 0x0000003F.
9 years, 6 months ago.
The example is for the LPC1768, which has its pins numbered in ascending order for easy usage, but besides that there are also the 'real' pinnames, which are like P2_20. So thats why that mask has different values than 21-26.
9 years, 2 months ago.
Hello guys I am in trouble too. I can' t really get how to use pins like P0.18 Which bitmask should I use? I need 8 pins used as a PortIn. Any Ideas? thanks
Thanks for this. I really like what you've posted here and wish you the best of luck with this blog! https://www.brotherprintersupportnumber.com/blog/how-to-fix-brother-printer-error-code-0x803c010b/
posted by Albert John 22 Nov 2018I post my answer here: https://os.mbed.com/questions/6441/Portin-data-for-OV7670/#answer16944
posted by Isaiah Yang 05 Sep 2019