This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

cc26xx - SWV over UART Question

Hello Ti folks,

I am implementing an application which uses a dedicated UART port to chatter with an external module. Previously, I was relying on a custom UART based debug printf function to accumulate to a circular buffer and dump on task idle to a hard-coded debug only UART.

However, now that I need that UART dedicated to the other module, I was exploring using the SWV features of the ARM CPU. I also noticed that the SWV unlock is documented in the RTOS guide. Could someone point me at *any* resource which might explain the steps needed to get this cc26xx system doing both a UART to an external device as well as some other mechanism for doing debug prints?

I considered toggling the UART between the two different sets of pins - but this won't really work since I need the UART to the external device to be "always on".

Any suggestions? I attempted to setup the sequence in my app start to enable SWV, but I still do not see any stuff produced on the UART.

Here is my start sequence:

    // 1. SET CPU_SCS:DEMCR:TRCEN = 1
    (*((volatile unsigned int *)(0xE000EDFC))) |= (1 << 24);

    // 2. Unlock ITM configuration by writing to the Lock Access Register CPU_ITM:LAR (see Section 2.7.3.36,
    //    LAR Register (Offset = FB0h) [reset = X]).
    (*((volatile unsigned int *)(0xE0000FB0))) = 0xC5ACCE55;

    // 3. Enable ITM by setting CPU_ITM:TCR.ITMENA (see Section 2.7.3.35, TCR Register (Offset = E80h)
    //    [reset = X]).
    (*((volatile unsigned int *)(0xE0000E80))) |= 0x00000001;

    // 4. Enable the desired stimulus port (0 to 31) in CPU_ITM:TER (see Section 2.7.3.33, TER Register
    //    (Offset = E00h) [reset = X] ).
    (*((volatile unsigned int *)(0xE0000E00))) |= 0x00000001;

    // 5. Change formatter configuration if needed CPU_TPIU:FFCR (see Section 2.7.5.6, FFCR Register
    //    (Offset = 304h) [reset = X]).
    // Ignore for now
    
    // 6. Change the pin protocol if needed CPU_TPIU:SPPR (see Section 2.7.5.4, SPPR Register (Offset =
    //    F0h) [reset = X]).
    (*((volatile unsigned int *)(0xE00400F0))) |= 0x00000002;

    // 7. Set the baudrate in CPU_TPIU:ACPR (see Section 2.7.5.3, ACPR Register (Offset = 10h) [reset = X]).
    (*((volatile unsigned int *)(0xE0040010))) = 625;

    // 8. The SWV can be mapped to DIO n by writing the correspond
    IOCPortConfigureSet(P_DEBUG_TX, IOC_PORT_MCU_SWV, IOC_STD_OUTPUT);

    while(true)
    {
        while(ITM_Port32(0) == 0x00);
        ITM_Port32(0) = 42;
    };

  • Shaba,

    I am unfamiliar with the SWV. I'll have to study the documentation on this feature before I can comment further. However I am puzzled by this statement: " I attempted to setup the sequence in my app start to enable SWV, but I still do not see any stuff produced on the UART." I thought you were dedicating the UART for another purpose? Do you mean you do not see the serial stream on the TPIU?

    Alan
  • Hey Alan,

    That is exactly what I meant. Sorry for the confusion. The thing is, I have a dual serial FTDI chip which I use as the debug interface into the cc26xx. The cc26xx UART will be used to drive some peripheral device on the board, and ideally I will map the SWV output to another "UART" so I can receive the data from the same host.

    Thanks for looking into this!

    -Shaba

  • Hi Shaba,

    Internally in the CC26xx apps team we have so far only used the IAR IDE + iJet debugger to get SWV output, needing only the IOC muxing step to be done manually.

    Have you looked at the ARM technical reference?
    infocenter.arm.com/.../arm_cortexm3_processor_trm_100165_0201_00_en.pdf

    I'll notify our Tools team of this post, perhaps they know who has a recipe for this. If you do figure it out, please post the solution - it could be interesting to put on the wiki as an example.

    Best regards,
    Aslak
  • That being said, this seemed to work for me. At least I get intelligble signals out (looking at logic analyzer)

    #define ITM_Port32(n) (*((volatile unsigned int *)(0xE0000000+4*n)))
    
    #include <inc/hw_memmap.h>
    #include <inc/hw_cpu_scs.h>
    #include <inc/hw_cpu_itm.h>
    #include <inc/hw_cpu_tpiu.h>
    
    /*
     *  ======== main ========
     */
    int main()
    {
      PIN_init(BoardGpioInitTable);
    
      IOCPortConfigureSet(IOID_25, IOC_PORT_MCU_SWV, IOC_STD_OUTPUT);
      
      HWREG(CPU_SCS_BASE + CPU_SCS_O_DEMCR) |= CPU_SCS_DEMCR_TRCENA;
      HWREG(CPU_ITM_BASE + CPU_ITM_O_LAR ) = 0xC5ACCE55;
      HWREG(CPU_ITM_BASE + CPU_ITM_O_TCR ) = CPU_ITM_TCR_ITMENA;
      HWREG(CPU_ITM_BASE + CPU_ITM_O_TER ) = 0x3F;
      HWREG(CPU_TPIU_BASE +  CPU_TPIU_O_ACPR) = 416;
      HWREG(CPU_TPIU_BASE + CPU_TPIU_O_SPPR) = CPU_TPIU_SPPR_PROTOCOL_SWO_NRZ;
      
      uint32_t i = 0;
      while(1)
      {
        while(ITM_Port32(1) == 0x00);
        ITM_Port32(1) = ++i;
      };

    The baudrate it seems is 48 MHz / 417 = ~115.107kbps.

    Please note that the format is a bit weird and proprietary, but I'm sure you can make sense of it somehow.

    Best regards,
    Aslak