Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 11 months ago.
Debug - why not?
Simple - this was changed from the standard version in desperation (IE the standard version is also defunct) - I now give up.
It compiles, it downloads, it seems to work but no debug info output.
I can press the 1 and 0 keys on TERA TERM and the LED responds as expected.
Where the printf results go is anybodies guess but one thing for sure they aren't appearing on the TERRY TERM window.
Any suggestions? - Other than get a new career, welcome.
- include "mbed.h"
Serial pc(USBTX, USBRX); DigitalOut led(LED1);
int main() { char c ; wait_ms(2000); pc.baud(9600);
pc.printf("Press '1' to turn LED1 ON, '0' to turn it OFF\n\r"); while(1) { c = pc.getc(); Read hyperterminal if (c == '0') { led = 0; OFF pc.printf("off\n\r"); wait_ms(1000); led=1; } if (c == '1') { led = 1; ON pc.printf("on \n\r"); } } }
1 Answer
6 years, 11 months ago.
Obvious helps to use the code tag. Is this what you have?
include "mbed.h" Serial pc(USBTX, USBRX); DigitalOut led(LED1); int main() { char c ; wait_ms(2000); pc.baud(9600); pc.printf("Press '1' to turn LED1 ON, '0' to turn it OFF\n\r"); while(1) { c = pc.getc(); if (c == '0') { led = 0; pc.printf("off\n\r"); wait_ms(1000); led=1; } if (c == '1') { led = 1; pc.printf("on \n\r"); } } }
A couple things. Pretty sure windows line endings are "\r\n" not the other way around. Be sure Tera Term is set to expect the right line ending (setup->terminal) and is set to the right Baud rate (setup->serial) or you may not see any text. Then obviously make sure the right port is open and that the OS Device driver is working.
You can start by just doing a simple printf in main without declaring any extra Serial object. Should be setup as an output by default at 9600 baud.
Thanks for the comments and ideas,
It turns out my Nucleo board is intermittently faulty with the USB connector.
Or at least that seems to be the trouble. Why it can download (and presumably communicate bi-directionally in the process) and then lose output messages when it's running the program is beyond me.
I've had the debug messages some times but usually I have to re-connect the USB cable (thereby reseting the board) every time I change the program. (pressing the reset button does nothing) Even then it's not guaranteed to give me the printf s.
Basically, I'm not too impressed with the ST nucleo/evaluation system.
I'm thinking KEIL might be a more productive setup even though it's more expensive - just to have a look see if I want to use the processors.
posted by 06 Dec 2017