1
\$\begingroup\$

I'm new to microcontroller programming. How can i configure one pin for input and another for output. If I am not wrong this could be done with GPIO registers that control device pins that are not connected to peripheral functions.

\$\endgroup\$
4
\$\begingroup\$

If you don't find the complete information in the datasheet you'll have to look at the LPC17xx family user manual. We're interested in Chapter 9: "LPC17xx General Purpose Input/Output (GPIO)". There you can read that FIODIR is the

Fast GPIO Port Direction control register. This register individually controls the direction of each port pin.

The direction for each I/O port/pin is controlled by FIO0DIR through FIO4DIR. Page 132 gives you the corresponding addresses.

If you don't know how to start looking in these rather long documents, use the "find" function in Acrobat Reader (CTRL-F) and look for "Direction".

\$\endgroup\$
3
  • \$\begingroup\$ You may also need to read chapter 8 "Pin connect block". \$\endgroup\$ – starblue Oct 2 '11 at 17:30
  • \$\begingroup\$ thx a lot ... And one more question : where i can get some sample code with arm cortex m3 programming ?? \$\endgroup\$ – nsinvocation Oct 2 '11 at 20:38
  • \$\begingroup\$ The corresponding CMSIS library has many demos, see also: stackoverflow.com/questions/7626102/… \$\endgroup\$ – Turbo J Oct 2 '11 at 20:55
0
\$\begingroup\$

Looking at the User Manual, it seems you would use the FIODIR register mentioned on pages 122-123.
There will be other things that affect the pins like the peripheral settings and Pin Function Select (see p104) so be sure to read the manual thoroughly.

\$\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.