It looks like you're new here. If you want to get involved, click one of these buttons!
Am using the MSP430 Microcontroller, the IAR compiler (free version). Am trying to get the program to execute a loop while it's polling a bit, and exit the loop as soon as the bit (USIIFG flag) is set.
At first the program would pass right over the loop and immediately execute the code after the loop
I thought it may be because, in that version of the program, the USSIFG flag was not properly declared as “volatile to prevent optimization”. So I declared it. That’s when the new error message “expected an identifier” showed up. It’s on the line where the USIIFG flag is declared at the top of the code*.
This is one of my first C programs, and I really don’t know what I’m doing.
All this program is supposed to do is transmit 16 bits over the SPI port, wait till the CPU clocks out the data, then continue to a short delay, and repeat. Everything works except the loop which waits for USIIFG to go high, before continuing.
What am I doing wrong in my attempt to poll that bit?
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR |= 0x01; // Set P1.0 to output direction
volatile unsigned int i; // volatile to prevent optimization
volatile unsigned int USISR; // volatile to prevent optimization
*volatile unsigned int USIIFG; // volatile to prevent optimization
#define RSTSENSOR 0xAAAA;
#define RSTSENSOR1 0x00;
j = 0;
USICTL0 |= USIPE7 + USIPE6 + USIPE5 + USIMST + USIOE; // Port, SPI master
USICTL1 |= USIIE; // Counter interrupt, flag remains set
USICKCTL = USIDIV_4 + USISSEL_2; // /16 SMCLK
USICTL0 &= ~USISWRST; // USI released for operation.
__intrinsic unsigned long __data16_read_USISR (unsigned short __addr);
// Read USISR Before writing to it.
USISR = RSTSENSOR; // init-load data
if (USIIFG == 0) goto LOOPSTART;
i = 40; // SW Delay
while (i != 0);