[SOLVED] why does SWO Viewer change SWO clock frequency

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED] why does SWO Viewer change SWO clock frequency

    I observe that when Edit->Configure is selected in the SWO Viewer, the data rate of ITM data coming out of the target SWO pin changes frequency. That is, the frequency of signal changes. Is that correct behavior?

    I also observe that running the SWO Viewer simultaneously with JLinkGDBServer.exe is not reliable. Should only one be open at a time?

    Can you suggest any checks when SWO data is going into the JLink SWO pin but data is not displayed in the SWO Viewer?
  • Hello,

    Thank you for your inquiry.

    That is, the frequency of signal changes. Is that correct behavior?

    Could you provide screenshots that show the behaviour you are seeing?

    I also observe that running the SWO Viewer simultaneously with JLinkGDBServer.exe is not reliable. Should only one be open at a time?

    They should be working next to each other. In what order are you enabling the programs? Does the behaviour change if you switch the start order?

    Can you suggest any checks when SWO data is going into the JLink SWO pin but data is not displayed in the SWO Viewer?

    You can see SWO trasactions int he J-Link Control panel in the SWV tab.

    Best regards,
    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Here is a video for your request of SWO Viewer changing the signal frequency of the SWO output data. The frequency changes when OK is selected in Config Dialog. The oscilloscope monitors the data going into the JLink SWO pin and shows how the speed changes when OK is selected. Equally important is that data streaming into the JLink SWO pin is not shown in the viewer. Data is streaming into the JLink on stimulus port 0 and stimulus port 1 but it is not shown in the window. The target CPU clock is 300,000kHz which agrees with the Measure Dialog which reports 304,000kHz so I don't believe that is the issue.

    youtu.be/2kr0FdegiWU

    In what order are you enabling the programs? Does the behaviour change if you switch the start order?

    Use these steps to reproduce the unresponsive behavior of Jlink and SWO Viewer running simultaneously.
    - Start a debug session in an IDE.
    - Open SWO Viewer. Establish a connection so SWO data is streaming in SWO Viewer.
    - Close SWO Viewer.
    - At this point, the debug session in the IDE becomes unresponsive. Single Line Stepping, Start, Stop, etc stops working.

    SWO Viewer hangs from 0:13 to 0:43 for 30 seconds. At 0:44, debug functions like single line stepping, run stop responding in the IDE. They worked before SWO Viewer was opened.
    youtu.be/rA-9U2kgJ2Q

    The post was edited 1 time, last by jheissjr ().

  • Hello,

    Thank you for providing the additional information.
    What target device are you trying to debug?
    Is it an eval board or custom hardware?
    To understand you correctly. You set the SWO clock manually in your target application?
    The reason the clock changes is because SWO viewer will check which swo clock speeds are available on your debug probe.
    Then it will set it to the highest possible value automatically.
    You seem to be using an older version of J-Link software. Could you update to the latest version and see if the behaviour changes?
    More information about the SWO Viewer default settings can be found in the J-Link user manual.

    Best regards,
    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • J-Link was upgraded when you said an outdated version of J-Link was being used. There is no difference when upgrading to V6.30. The behavior still occurs with V6.30.

    Target - Atmel Cortex-M7 ATSAMS70N20
    SWO Clock - Set manually in application, code provided below.
    Board - Custom, schematic provided below.

    C Source Code

    1. void init_swo(const uint32_t cpuCoreFreqHz) /* cpuCoreFreqHz = 300000000 */
    2. {
    3. uint32_t SWOSpeed = 19200; /* default 19.2k baud rate */
    4. uint32_t SWOPrescaler = (cpuCoreFreqHz/(SWOSpeed*2)) - 1; /* SWOSpeed in Hz, note that cpuCoreFreqHz is expected to be match the CPU core clock */
    5. /* Configure the TPIU - pages and info from ATSAMS70N20 datasheet */
    6. CoreDebug->DEMCR = (1UL<<24); /* page 83, step 1 - "Debug exception and monitor register": bit 24 is TRCENA which enables DWT and ITM units. page 766 at https://static.docs.arm.com/ddi0403/eb/DDI0403E_B_armv7m_arm.pdf */
    7. TPI->SPPR = 0x00000002; /* page 83, step 2 - "Selected PIN Protocol Register": Select which protocol to use for trace output (2: SWO UART/NRZ, 1: SWO Manchester encoding) */
    8. TPI->FFCR = 0x00000100; /* page 83, step 3 - Formatter and Flush Control Register */
    9. TPI->ACPR = SWOPrescaler; /* page 83, step 4 - "Async Clock Prescaler Register". Scale the baud rate of the asynchronous output */
    10. ITM->LAR = 0xC5ACCE55; /* ITM Lock Access Register, C5ACCE55 enables more write access to Control Register 0xE00 :: 0xFFC */
    11. ITM->TCR |= ((1UL<<16) | (1UL<<4) | (1UL<<2) | (1UL<<0)); /* pg 776, ITM Trace Control Register at https://static.docs.arm.com/ddi0403/eb/DDI0403E_B_armv7m_arm.pdf;
    12. - set TraceBusID to 1,
    13. - enable SWOENA (async clocking of timestamp counter
    14. - enable SYNCENA (Synchronization packet transmission for a synchronous TPIU)
    15. - enable ITMENA (enable ITM)*/
    16. ITM->TER = (0xFFFF); /* ITM Trace Enable Register. Each bit location corresponds to a virtual stimulus register; when a bit is set, a write to the appropriate stimulus location results in a packet being generated, except when the FIFO is full.
    17. - only ITM_TER0 is implemented as ITM_TER according to one register in .h file. Registers ITM_TER1 to ITM_TER7 seem unimplemented
    18. - ITM_TER0.0 - ITM_STIM0 (ITM->PORT[0])
    19. - ITM_TER0.1 - ITM_STIM1 (ITM->PORT[1])
    20. - ITM_TER0.31 - ITM_STIM31 (ITM->PORT[31]) */
    21. DWT->CTRL = 0x400003FE; /* DWT_CTRL */
    22. /* Check if Trace Control Register (ITM->TCR at 0xE0000E80) is set */
    23. if ((ITM->TCR & (1UL<<0)) == 0) /* check Trace Control Register if ITM trace is enabled (ITM->TCR.ITMENA)*/
    24. while(1){} /* not enabled? */
    25. /* Check if the requested channel stimulus port (ITM->TER at 0xE0000E00) is enabled */
    26. if ((ITM->TER & (1UL<<0))==0) /* check Trace Enable Register if requested port is enabled */
    27. while(1){} /* requested port not enabled? */
    28. }
    29. void SWO_send_char(void)
    30. {
    31. while (ITM->PORT[0].u32 == 0) /* Wait until STIMx is ready, then send data */
    32. {}
    33. ITM->PORT[port_bit].u8 = 'A';
    34. }
    Display All
    Images
    • schematic.PNG

      46.87 kB, 1,633×843, viewed 593 times

    The post was edited 2 times, last by jheissjr ().

  • Hello,

    SWO Clock - Set manually in application, code provided below.


    This will not work. For SWO to work with a debug probe, target and debug probe need to set the same SWO speed which both support with their dividers.
    So each time you start SWOViewer or any debug software that supports SWO your application ITM settings will be overwritten.
    To use SWO remove any SWO init from your application and let J-Link handle it, otherwise it will not work.

    Best regards,
    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Nino,

    I used this sequence. Open JLink.exe. Connect to the target. Open SWO Viewer. Select Measure in the dialog. When Measure is selected this message is given. SWO Viewer stops responding after closing the message.
    Images
    • swo viewer message.GIF

      84.07 kB, 685×701, viewed 663 times
  • Hello,

    SWOViewer works with any Cortex-M device that has a SWO pin available.
    In some cases the devices are extraordinary as they do not set SWO clock = CPU clock as most devices do, but they use a dedicated slower peripheral clock instead.
    Both the Nordic and Atmel devices do this.
    More information can be found here: forum.segger.com/index.php?page=Thread&threadID=4852

    Best regards,
    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • I am in contact with Microchip to get the SWO base clock frequency in the SAM S/E/V family (Microchips Cortex-M7 parts). They said the base clock is a clock called PCK[3] (an internal programmable clock line)

    They provided initialization code.

    C Source Code

    1. //The SWO must be configured to use the same PCK3 as the ETM...Here is some init code:
    2. //-----------------------------------------------------------------------------
    3. static void swo_init(void)
    4. {
    5. CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
    6. PMC->PMC_SCDR = PMC_SCDR_PCK3;
    7. while (PMC->PMC_SCSR & PMC_SCSR_PCK3);
    8. //PMC->PMC_PCK[3] = PMC_PCK_CSS_MAIN_CLK | PMC_PCK_PRES(18); // 18 - fastest ~315 kHz / kBps
    9. PMC->PMC_PCK[3] = PMC_PCK_CSS_MCK | PMC_PCK_PRES(3); // For 150 MHz
    10. //PMC->PMC_PCK[3] = PMC_PCK_CSS_MCK | PMC_PCK_PRES(0);
    11. PMC->PMC_SCER = PMC_SCER_PCK3;
    12. while (0 == (PMC->PMC_SR & PMC_SR_PCKRDY3));
    13. TPI->SPPR = 0; // 0 - Parallel, 1 - Manchester, 2 - UART
    14. TPI->FFCR = 0x103; //0x100; // Is this read-only? 11.9.2
    15. TPI->ACPR = 12; //208; // Prescale
    16. TPI->CSPSR = (1 << 3); // Port size = 4 bits
    17. //TPI->FSCR = 100;
    18. ITM->LAR = 0xC5ACCE55;
    19. ITM->TCR = (1 << ITM_TCR_TraceBusID_Pos) | ITM_TCR_SWOENA_Msk | ITM_TCR_DWTENA_Msk |
    20. ITM_TCR_SYNCENA_Msk | ITM_TCR_TSENA_Msk | ITM_TCR_ITMENA_Msk;
    21. ITM->TER = 0xffffffff;
    22. ITM->TPR = 0;
    23. DWT->LAR = 0xC5ACCE55;
    24. DWT->CTRL = (1 << DWT_CTRL_PCSAMPLENA_Pos) | (1 << DWT_CTRL_EXCTRCENA_Pos) |
    25. (1 << DWT_CTRL_CYCCNTENA_Pos) | (1 << DWT_CTRL_CYCTAP_Pos) |
    26. (15 << DWT_CTRL_POSTINIT_Pos) | (15 << DWT_CTRL_POSTPRESET_Pos);
    27. }
    Display All
    Images
    • atmel SWO base clock.png

      110 kB, 1,212×683, viewed 616 times
  • Hello,

    Thank you for your additional information.
    From J-Link perspective it should be sufficient to simply enable PCK3 and pass the PCK3 clockspeed to J-Link user a J-Link scriptfile.
    Functions SWO_GetSWOBaseClock() and SWO_EnableTarget() can be used for that.
    More information can be found in the J-Link user manual.

    All the remaining ARM specific ITM,DWT etc. init is already done by J-Link.
    We do not recommend interfering with that settings as J-Link negotiates the fastest possible SWO speed with the target.
    If you overwrite this in your application SWO might not work.

    We will implement a J-Link Script file for that particular device that will be part of our J-Link software install so SWO works out of the box for this special device as well.

    Best regards,
    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hello,

    Quick update.
    We have implemented a generic SWO init for SAME70 device series which will be available as a script file in the next J-Link software release version.

    This thread will be closed now.

    Best regards,
    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.