This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP432E401Y: Configuring PA0-PA7 as an input port

Part Number: MSP432E401Y

I want to read the state of the pins PA0-PA7 which seems to me should be a very simple thing to do.  However, reading section 17.4 of SLAU723A it has 15 steps to configure the GPIO pins which starts by enabling a clock to the port.

It's not clear to me why a clock is involved when you want to read the state of the pins and I also don't understand why it would take 15 steps to do something so simple.

So before I spend the next week trying to go through all those steps I am hoping someone can tell me a simple way to setup that port so I can read the value of those 8 pins.

Thank you.

  • After reset, the PAx pins are configured as inputs (GPIOA->DIR==0). Since that's what you want, strictly speaking you don't need to do anything to configure them. You can read the pin states from GPIOA->DATA. (The TRM would refer to this as DATA[0xFF], but I'm using the CMSIS definition.) If you decide you want outputs and/or alternate functions, that's where (some of) those extra steps come in.

    You do need to supply ("gate") a bus clock to the GPIOA peripheral so you can see the register space. This involves setting (in your case) the low-order bit of RCGCGPIO to 1, then waiting for the low bit of PRGPIO to go to 1 (it's very quick, so you might as well spin). Using driverlib, this looks something like:

    > SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

    > while (!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOA)) /*EMPTY*/;

  • I'm still not able to get anything that makes any sense.  I'm using using assembly code and CCS in debug mode.  I wrote a value 01 to address 0x40058608 which should be setting the low order bit of RCGCGPIO for port A.  Pointing the Memory Browser to that memory location its value is 0xFD and doesn't change whether I set it to a 01 or not.

    The value at 0x40058000 also didn't change as I was toggling the voltage on the PA5 header pin on the development board.

    Can you see what I'm doing wrong here?

  • 1) Sorry, I forgot you also need to set GPIOA->DEN=0xFF (all 8 pins).

    2) RCGCGPIO is at 0x400FE608, and PRGPIO at 0x400FEA08. If you were able to read 0x40058000 (without setting RCGCGPIO) maybe some other code has already switched on the GPIOA clock.

    3) 0x40058000 is the DATA value for PA0 (only). To get all 8 bits look at 0x400583FC.

  • It worked.  Thank you so much.  Now I can continue making progress on my application.