Printf permite mostrar mensajes en la ventana “console” de Code Compose Studio.
1. La parte aburrida: configurar el Code Composer Studio.
Seleccionar el nivel de soporte que queremos en printf. Hay tres valores posibles:
- full: Soporta todos los formatos.
- nofloat: Excluye el soporte para valores de punto flotante (%f, %F, %g, %G, %e, %E).
- minimal: Soporta valores integer, char y string.
Ampliar el espacio en el heap para que pueda funcionar printf. Minimo 320 bytes.
2. Incluir cabeceras.
#include <stdio.h>
3. Usando printf para ayudar en la depuración.
while(1) { for (n=2; n >0; n--) { //LED_RED_ON printf("Rojo %d\n", n); MAP_GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0); pause(1000); //LED_RED_OFF MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0); pause(100000); } //LED_RGB_Green_ON printf("Verde\n"); MAP_GPIO_setOutputHighOnPin(GPIO_PORT_P2, GPIO_PIN1); pause(1000); //LED_RGB_BLUE_OFF; MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P2, GPIO_PIN1); pause(100000); }
4. Referencias.
ti.com wiki
Printf support for MSP430 CCSTUDIO compiler
How To Add Printf Support For The MSP432 Launchpad Serial Port