This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Difficulty in understanding PINSEL0 of LPC2378

PINSEL0 |= 0x40000000; /* Enable TxD1 in P0.15 */ PINSEL1 |= 0x00000001; /* Enable RxD1 in P0.16 */

Howcome P0.15 is represented as 0x40000000 ?

I went through the user manual of LPC2378, still i didnt understand the code ....

Similarly I am unable to understand how to select pins of LPC2378 .....

Can anyone help me ?

  • The manual is very clear. P0 is 32 bit wide. Each pin requires 2 bits to configure. So you have PINSEL0 to control P0.0..P0.15, and PINSEL1 to control P0.16..P0.31.

    P0.15 is the 16th pin so it is configured using the two most significant bits in PINSEL0. I.e. 0x80000000 and 0x40000000.

    And P0.16 is the 17th pin so it is configured using the two least significant bits in PINSEL1 - 0x00000001 and 0x00000002.

    All this is very well described in the user manual for the processor.

    But remember that depending on previous values of PINSEL0 and PINSEL1, you may need to do more than just modify a single bit as in your two examples. They assume that the other configuration bit for the GPIO pin already are in the correct state.