Lesson 04 - Debug/debug_swo.c
void OnReset(void)
{
    uint32_t counter;

    /* Initialize LED pin as output */
    NRF_P0->PIN_CNF[LED_PIN] =
          (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos)
        | (GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_PULL_Pos);

    /* Enable SWO debug output pins - 4MHz serial mode */
    NRF_CLOCK->TRACECONFIG =
        (CLOCK_TRACECONFIG_TRACEMUX_Serial << CLOCK_TRACECONFIG_TRACEMUX_Pos)
      | (CLOCK_TRACECONFIG_TRACEPORTSPEED_4MHz << CLOCK_TRACECONFIG_TRACEPORTSPEED_Pos);

    /* Reset previous channel settings */
    ITM->LAR  = 0xC5ACCE55;
    ITM->TCR  = ITM->TER = 0x0;

    /* Wait for debugger to connect */
    while(!((ITM->TCR & ITM_TCR_ITMENA_Msk) && (ITM->TER & (1<<CHANNEL_DEBUG))));

    /* Print endless hello world */
    counter = 0;
    while(1)
    {
        PrintNumber(counter++);
        PrintStr(": Hello World!\n\r");
    }

}
/* Reset function called by CPU upon start */
Reset function called by CPU upon start
Reset function called by CPU upon start
void OnReset(void)
{
    uint32_t counter;
    NRF_P0->PIN_CNF[LED_PIN] =
          (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos)
        | (GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_PULL_Pos);
    NRF_CLOCK->TRACECONFIG =
        (CLOCK_TRACECONFIG_TRACEMUX_Serial << CLOCK_TRACECONFIG_TRACEMUX_Pos)
      | (CLOCK_TRACECONFIG_TRACEPORTSPEED_4MHz << CLOCK_TRACECONFIG_TRACEPORTSPEED_Pos);
    ITM->LAR  = 0xC5ACCE55;
    ITM->TCR  = ITM->TER = 0x0;
    while(!((ITM->TCR & ITM_TCR_ITMENA_Msk) && (ITM->TER & (1<<CHANNEL_DEBUG))));
    counter = 0;
    while(1)
    {
        PrintNumber(counter++);
        PrintStr(": Hello World!\n\r");
    }
}
void OnReset ( void ) { uint32_t counter ; NRF_P0 -> PIN_CNF [ LED_PIN ] = ( GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos ) | ( GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_PULL_Pos ) ; NRF_CLOCK -> TRACECONFIG = ( CLOCK_TRACECONFIG_TRACEMUX_Serial << CLOCK_TRACECONFIG_TRACEMUX_Pos ) | ( CLOCK_TRACECONFIG_TRACEPORTSPEED_4MHz << CLOCK_TRACECONFIG_TRACEPORTSPEED_Pos ) ; ITM -> LAR = 0xC5ACCE55 ; ITM -> TCR = ITM -> TER = 0x0 ; while ( ! ( ( ITM -> TCR & ITM_TCR_ITMENA_Msk ) && ( ITM -> TER & ( 1 << CHANNEL_DEBUG ) ) ) ) ; counter = 0 ; while ( 1 ) { PrintNumber ( counter ++ ) ; PrintStr ( " \n \r " ) ; } }
Reset function called by CPU upon start
Reset function called by CPU upon start
/* Initialize LED pin as output */ /* Enable SWO debug output pins - 4MHz serial mode */ /* Reset previous channel settings */ /* Wait for debugger to connect */ /* Print endless hello world */