Serial Wire Output (SWO) viewer for tracing purposes. Tested on F401 and ST-LINK Utility as well as for F103 and Segger J-Link SWO viewer.
Dependents:
WiFi_Scanner
mbed_nucleo_swo
DISCO-F429ZI_LCDTS_demo_richard
TEST_SM_SPEED
1 comment:
It is not an SWO issue and should be solved like like any other C/C++ case where you have an instantiation in one file and you want to use that variable in another file. You need to declare the variable as ''extern" in the second file to make it accessible. So, instantiate in main() as usual, and modify the second file as shown below:
#include "mbed.h"
#include "myfunction.h"
//The next include is needed to ensure that the compiler recognises ''SWO_Channel''
#include "SWO.h"
extern SWO_Channel SWO; // SWO is instantiated in main(), we just reference it here
void myfunction() {
SWO.printf("\r\nHello World from myfunction\n");
// .. your code
}
The compiler will now be happy with this second file and the linker will connect the ''external'' SWO variable to the one instantiated in main.
Alternatively, you could pass the variable around as a parameter, but the solution above is easier.
What approach have you used to try SWO in other files?
I have successfully tested the solution shown above. It is included in the updated SWO test example.
It is not an SWO issue and should be solved like like any other C/C++ case where you have an instantiation in one file and you want to use that variable in another file. You need to declare the variable as ''extern" in the second file to make it accessible. So, instantiate in main() as usual, and modify the second file as shown below:
The compiler will now be happy with this second file and the linker will connect the ''external'' SWO variable to the one instantiated in main. Alternatively, you could pass the variable around as a parameter, but the solution above is easier.
What approach have you used to try SWO in other files?
I have successfully tested the solution shown above. It is included in the updated SWO test example.