0
\$\begingroup\$

I'm trying to make a project using the ATSAM4LS2A microcontroller (Cortex M4), and i'm using the AtmelICE debugger. The thing is the pinout for the SWD mode also has, beside the SWCLK and SWDIO pins, also the SWO pin (which should be optional). The problem is that the SWO pin is the same as the SCLK pin that i'm using for the SPI (trying to talk to a CC1101 transceiver). Even if i don't connect the SWO pin, when i'm debugging and trying to read a byte from SPI i always get 0, even though i'm pretty sure it should be different. So, my first question is, how would i be able to test that the SCLK pin in working in SCLK mode and not SWO mode? Second question: How can i disable the SWO pin in case it isn't disabled automatically when it is not connected? (if possible). Thanks.

\$\endgroup\$
  • 1
    \$\begingroup\$ There should be some kind of "function select" register, defining the function of this pin. Look at the datasheet/prog manual. \$\endgroup\$ – Eugene Sh. Jun 2 '16 at 17:41
  • \$\begingroup\$ When you say while I'm debugging, do you mean you have an active toolchain connection over SWD concurrently? It is possible that the toolchain has done some default configuration to 'help' you. I can tell you for sure, SWO doesn't know if you connected to monitor it, the protocol is all one-way. \$\endgroup\$ – Sean Houlihane Jun 2 '16 at 22:31
2
\$\begingroup\$

I kinda forgot i posted this question here, but in the meantime I found the answer on some other site that I can't find right now.

You can disable the SWO functionality simply through this code:

#include <core_cm4.h>
void disableSWO(void)
{
    CoreDebug_Type *core = CoreDebug_BASE;
    core->DEMCR = (0<<CoreDebug_DEMCR_TRCENA_Pos);
}

Just call disableSWO() and SWO pin is disabled. I could debug while still keeping the SPI working.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.