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.

MSP-EXP430FR5969: MSP430

Part Number: MSP-EXP430FR5969

Hello experts,

I have been new to the embedded world for the last year, and I have stepped away from MSP430 code dev for a few weeks and am having difficulty getting back into the semantics.

I am simply trying to control an individual pin as GPIO, however, I keep running into the errors such as: "expected a field name" or "expression must have struct or union type" when trying to configure individual pins as GPIO, such as P4OUT.BIT6

For example, I would like to configure P4.6 (onboard LED) as an output in the example code "Flashing the LED".

My code looks like this:


#include "msp430.h"
int main(void)


{
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
PMMCTL0 = PMMPW; // Open PMM Module
PM5CTL0 &= ~LOCKLPM5; // Clear locked IO Pins
P1DIR |= 0x01; // Set P1.0 to output direction
P4DIR.BIT6 |= 0x01;

for (;;)
{
volatile unsigned int i;        // volatile to prevent optimization

P1OUT ^= 0x01;                // Toggle P1.0 using exclusive-OR
P4OUT.BIT6 ^= 0x01;       // Toggle P4.6 using exclusive-OR

i = 10000; // SW Delay
do i--;
while (i != 0);
}
}

I have ran this code in the past with similar semantics, and I have not had issues.

  • > P4DIR.BIT6 |= 0x01;

    > P4OUT.BIT6 ^= 0x01;       // Toggle P4.6 using exclusive-OR

    Try instead:

    > P4DIR |= BIT6;

    > P4OUT ^= BIT6;       // Toggle P4.6 using exclusive-OR

    ----------

    PMMCTL0 = PMMPW; // Open PMM Module

    This isn't needed (in the FR5 series) in order to clear LOCKLPM5. For (other) cases where it is needed, it's usually better to express it as

    > PMMCTL0_H = PMMPW_H; // Open PMM Registers for write

    so you don't unintentionally clear SVSHE.

    ------------

    I encourage you to look over the TI Example suite, which can offer useful reminders, and in some cases paste-able code.

    https://dev.ti.com/tirex/explore/node?node=A__AL2dmw21b-kJdwBXB2JdHw__msp430ware__IOGqZri__LATEST

  • I just want to say, from the bottom of my black heart, how much joy this brings me.

    I had this working (I think my issue was that I was using a different system header file at the time), but to see it come back to life after taking the winter break off and completely forgetting the details - wow. Thank you.

**Attention** This is a public forum