I am trying to run "Hello world", the most simple and basic code there is, on an MSP430 Launchpad (specifically,
If it works, the printed text should come out of a CIO terminal.
CodePudding user response:
The statment:
"the most simple and basic code there"
is to to really underestimate complexity of printf()
.
First of all you have to define what output device is associated with stdout. For output in the debug console, you need to enable CIO in the project debug properties (apparently... I am just Googling this stuff).
Outputting that way however is only useful in debug because you need CCSTUDIO debugger running to see the output.
With respect to your ultimate goal:
"displaying that comparator information on a computer screen."
... for that you will need to implement the low level I/O required to support stdio streams. You might for example map stdio to the Launchpad's "Application/Backchannel UART" (§2.2.4 of the Launchpad manual) which is an MSP430 UART1/USB bridge. Then you can interact with the board using a terminal emulator such as TeraTerm or PuTTY on the PC. That has the advantage of appearing on your host as a virtual serial port via the Launchpad's USB connection.
To see how to create a suitable device driver and redirect stdio from the debugger to the Application UART see §7.2.4 of the Compiler reference manual, and the preceding section on the required device driver interface.
You might choose not to go to the complexity of integrating the Application UART with stdio (though I find it hard to believe someone has not already done that work), and simply read/write directly to the UART. You could also bypass the standard library's stdio implementation and implement your own simplified formatted I/O. For example this TinyPrint implementation where for tfp_printf()
to work you need only implement a single putc()
function to write a character to whatever output device you choose (UART1 in this case).
Note that the application UART is used for the Launchpad's Out-of-Box Demo to communicate with a GUI interface on the host. If you have the necessary PC GUI and serial I/O development skills, you could ultimately do something similar, which might be more compelling than simple terminal I/O. The source code for that demo (the embedded here).