Hello, I am using STM32F407 Discovery, and would like to send data to the computer without the USART cable (I am only using USB-MiniB cable).
So to view the voltage read by the ADC (of STM32F4) I use printf function, as follows:
int fputc(int c, FILE *stream) { return(ITM_SendChar(c)); }
printf(...)
Since I need to read then the voltage values on the computer (by matlab), how can I access the debug serial viewer? Or how can I retarget the printf function to write data in a txt file?
I tried also to use fopen,fprintf but it is not working.
I'm not aware of a simple method to pipe SWV output to a file/application. A Serial or VCP would be easier.
Consider using an STM32F4-DIS-BB which would provide a serial connection, and a MicroSD on to which a FatFs implementation could write files with.
This might be instructive to you:
www.youtube.com/watch
So I definitively need an USART. No way to write data to text file on the computer with only USB-MiniB cable?
Probably You can create a Virtual Comport. The way I think it works is you use a USART but you have to assign the proper pins to use the USB ST LINK Adapter. One important thing is to install the ST Link Drivers so the virtual comport can be seen by the computer. You still have to write serial port code. You also have to assign the proper pins for the USART.
There are some virtual comport examples. But I looked for your board did not see for that board. It should be easy though to get it to work. If you can not get it to work you can always just create a serial port application.
Not sure I'm suggesting it is impossible, as someone with enough Windows coding skills and knowledge of the ST-LINK DLLs and protocols, could probably stream SWV (Serial Wire Viewer) output to a file. I'm sensing you're not that guy, and I've got much more practical solutions. One of the tricks to success is to pick the path of least resistance/complexity, not the one with the most.
The STM32F407 Discovery board doesn't not support a Virtual Serial Port via the ST-LINK connection (the mini USB), other ST-LINK firmware variations do, this one does not.
You could create a VCP using the primary USB connector of the F407 (the micro USB).