Other Parts Discussed in Thread: ADS1231, ADS1231REF,
Tool/software: Code Composer Studio
Hi,
I'm interfacing an ADS1231REF board with a MSP430F5529LP, in which the 24 bit digital code from the ADS1231 is converted into a meaningful weight value. At the beginning of my program, I ask the user what unit they would like to display their weight in using the scanf command. Depending on the integer (between 0 and 4) the user inputs, the corresponding unit is selected.
However, when I play my program, it properly executes the printf function, but skips over scanning for the user input and returning the "unit" variable. My question is, how can I debug scanf commands in embedded programs? I've attached the code below. I appreciate any help!
uint8_t selectUnit(void)
{
uint8_t unit;
printf("What unit would you like your weight to display in?");
fflush(stdout);
scanf("%d", &unit);
printf("The unit value is %d\n", unit);
return unit;
}