I have been searching if there is CCS has scanf in its libraries for the MSP430. I only found the CCS has printf for the MSP430.
Why does CCS have scanf? Can MSP430 support the function?
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.
I have been searching if there is CCS has scanf in its libraries for the MSP430. I only found the CCS has printf for the MSP430.
Why does CCS have scanf? Can MSP430 support the function?
Yes, the following program was created in CCS 6.1 for a MSP430F5529:Rodney Wong said:Can MSP430 support the function?
#include <msp430.h> #include <stdio.h> /* * main.c */ int main(void) { int number; WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer while (1) { printf ("Enter integer value>"); if (scanf ("%d", &number) == 1) { printf ("Value = %d\n", number); } else { printf ("Invalid integer entered\n"); /* @todo Flush standard input to stop scanf() continuously returning a failure * after an invalid integer has been entered. */ fflush (stdin); } } return 0; }
The CCS debugger re-directs standard input and output through the CIO console.
Note that to get scanf and printf to work with MSP430 devices requires a Heap Size and Stack Size ot around 1024 bytes (exact size required not investigated but the program failed when smaller sizes were used).
See http://processors.wiki.ti.com/index.php/CIO_System_Call_Protocol for some background on how CIO is implemented by CCS.
**Attention** This is a public forum