SWO output on imx7ulp in IAR EWARM

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SWO output on imx7ulp in IAR EWARM

724 Views
klaas
Contributor III

Hi all,

I'm trying to setup SWO debug output for my imx7ulp in IAR EWARM. I did set up the following minimal example:

/*
 * Copyright (c) 2015, Freescale Semiconductor, Inc.
 * Copyright 2016-2017 NXP
 * All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include "pin_mux.h"
#include "clock_config.h"
#include "board.h"
#include "fsl_debug_console.h"
#include "fsl_gpio.h"

#include "stdio.h"
#include "assert.h"

#define BOARD_LED_GPIO     GPIOA
#define BOARD_LED_GPIO_PIN 8U

void delay(void)
{
    volatile uint32_t i = 0;
    for (i = 0; i < 800000; ++i)
    {
        __asm("NOP"); /* delay */
    }
}

/*!
 * @brief Main function
 */
int main(void)
{
    /* Define the init structure for the output LED pin*/
    gpio_pin_config_t led_config = {
        kGPIO_DigitalOutput,
        0,
    };

    /* Board pin, clock, debug console init */
    BOARD_InitPins();
    BOARD_BootClockRUN();
    BOARD_InitDebugConsole();
    CLOCK_EnableClock(kCLOCK_Rgpio2p0);
    
    uint32_t prescaler = 72000000 / 24000 - 1U;

    /* enable the ITM and DWT units */
    CoreDebug->DEMCR = CoreDebug_DEMCR_TRCENA_Msk;

    if ((CoreDebug->DEMCR & CoreDebug_DEMCR_TRCENA_Msk) == 0U)
    {
        assert(false);
    }

    /* Lock access */
    ITM->LAR = 0xC5ACCE55U;
    /* Disable ITM */
    ITM->TER &= ~(1UL << 0U);
    ITM->TCR = 0U;
    /* select SWO encoding protocol */
    TPI->SPPR = (uint32_t)0U;
    /* select asynchronous clock prescaler */
    TPI->ACPR = prescaler & 0xFFFFU;
    /* allow unprivilege access */
    ITM->TPR = 0U;
    /* enable ITM */
    ITM->TCR = ITM_TCR_ITMENA_Msk | ITM_TCR_SYNCENA_Msk
#ifdef ITM_TCR_TraceBusID_Msk
               | ITM_TCR_TraceBusID_Msk
#elif defined(ITM_TCR_TRACEBUSID_Msk)
               | ITM_TCR_TRACEBUSID_Msk
#else
#endif
               | ITM_TCR_SWOENA_Msk | ITM_TCR_DWTENA_Msk;
    /* enable the port bits */
    ITM->TER = 1UL << 0U;
    

    /* Print a note to terminal. */
    printf("\r\n GPIO Driver example\r\n");
    printf("\r\n The LED is blinking.\r\n");

    /* Init output LED GPIO. */
    GPIO_PinInit(BOARD_LED_GPIO, BOARD_LED_GPIO_PIN, &led_config);

    while (1)
    {
        delay();
        ITM_SendChar('c');
        GPIO_PortToggle(BOARD_LED_GPIO, 1u << BOARD_LED_GPIO_PIN);
        printf("\r\n The LED is blinking.\r\n");
    }
}

I configured IAR according to the instructions from SEGGER (section  'How to configure SWO for EWARM V8'): https://wiki.segger.com/IAR_EWARM

I also tried with the code snippets provided in the above segger link.

All of this does not work. Any Idea what I'm doing wrong here? Should SWO debug output in general work with the imx7ulp?

Thanks
Klaas

Labels (1)
Tags (1)
0 Kudos
2 Replies

644 Views
klaas
Contributor III

Hi all,

I'm still waiting for a response here. Any idea is highly appreciated

Thanks
Klaas

0 Kudos

711 Views
klaas
Contributor III

Hi all,

no idea? I could really use some help on this issue.

Thanks
Klaas

0 Kudos