Hi,
I encounter a very strange problem.
** In the following problem description, I don't use TI provided code. I have designed my own RTOS and framework. **
With CC2640, I would like to output data through SWO by different STIM ports. For example, task 1 is using STIM port 0 while task 2 is using port 1. OK, everything works fine when I download program and start to run the target by CCS. I have also designed a PC (Linux) viewer to view the SWO output data. Messages from two tasks can be separated easily by parsing SWO SWIT packets in the PC viewer.
Now, I want to disconnect target from debugger. In CCS, I can do it by menu command "disconnect target". This will keep the target firmware "free" running. Everything still works fine. With XDS100v3 cable still inserted in PC USB port, the PC viewer can continuously get messages from SWO. Then, I unplug the XDS100v3 cable from PC. The viewer stop showing message. After that, I plug XDS100v3 cable to PC again, the viewer continues to show message. Good, everything is as expected.
Then, I power-cycle the target. Now, the firmware in CC2640 is re-launched by boot loader after power-on. I can see some messages output from SWO. But the data are corrupted. Some text are correct, but some are just garbage.
I guess there might be some registers pre-set by the debugger before "run" the target. So, I remove the default GEL file within the .ccxml file. Repeat the above experiment, but the result is the same.
Then I disable task 2. So, only STIM port 0 is used by task 1. Now, the data is correct no matter it is launched by debugger or by power-on.
I have repeated the experiment again and again. It is confirmed that the SWO output from multiple STIM ports are corrupted when the target is executed from power-on (by boot loader?). If the program is executed by debugger (CCS) then everything is fine.
I re-read ARM TRM and CC2640 TRM again and again to ensure TPIU/ITM... registers are well configured. They should be, otherwise, I should not be able to get SWO output at all.
Finally, I have to call for help...