0
\$\begingroup\$

I am reading lpc1347 manual (GPIO section) and I have seen one sentence which I don't understand. The problem is WORD register which controls pin states. Quotation:

"Each GPIO pin has a word register in this address range. Any byte, balfword or word read in this range will be all zeros if the pin is low or all ones if the pin is high..."

I can access WORD register via

pGPIO->B[0]

It's word access but how can I read it via halfword or byte? Should I make a own pointer and read value from memory? If yes, should I start read from LSB or MSB?

\$\endgroup\$
3
  • \$\begingroup\$ You're reading about the bit-banding region. The word aliases a single bit. I doesn't matter whether you read a byte, halfword, or word. Either way the only information obtained is whether the aliased bit is set or clear. \$\endgroup\$
    – kkrambo
    Sep 21 '17 at 16:53
  • \$\begingroup\$ I have heard that lpc 13xx doesnt support bit-banding. Doesnt it? The WORD register base address is 0x50001080 so it isnt in bit-banding region. infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0552a/… \$\endgroup\$
    – Mati33
    Sep 21 '17 at 19:11
  • \$\begingroup\$ Sorry, maybe this is just something similar to bit-banding. After looking at the User Manual, I'm guessing that pGPIO->B refers to the "Byte pin registers" and perhaps there is a pGPIO->W that refers to the "Word pin registers" (see Table 114). \$\endgroup\$
    – kkrambo
    Sep 21 '17 at 21:17
1
\$\begingroup\$

You can read a half-word or byte by defining a variable of the appropriate size at the appropriate address (or via a pointer, which has the same effect).

But why would you? Reading a byte or half-word is not faster than reading a full word, maybe even slower. If it were any use, it would probably be in the (mbed or similar) interface definition.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.