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.

CC2674P10: Why enter this function

Part Number: CC2674P10


Tool/software:

Hello​

 I run the demo "uart2echo_LP_EM_CC2674P10_nortos_ticlang",

int main(void)
{
    Board_init();
    // initUART();
    /* Start NoRTOS */
    NoRTOS_start();

    /* Call mainThread function */
    mainThread(NULL);

    while (1) {}
}
void *mainThread(void *arg0)
{
    char input;
    const char echoPrompt[] = "Echoing characters:\r\n";
    UART2_Handle uart;
    UART2_Params uartParams;
    size_t bytesRead;
    size_t bytesWritten = 0;
    uint32_t status     = UART2_STATUS_SUCCESS;

    /* Call driver init functions */
    GPIO_init();

    /* Configure the LED pin */
    GPIO_setConfig(CONFIG_GPIO_LED_0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);

    /* Create a UART where the default read and write mode is BLOCKING */
    UART2_Params_init(&uartParams);
    uartParams.baudRate = 115200;

    uart = UART2_open(CONFIG_UART2_0, &uartParams);

    if (uart == NULL)
    {
        /* UART2_open() failed */
        while (1) {}
    }

    /* Turn on user LED to indicate successful initialization */
    GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_ON);

    UART2_write(uart, echoPrompt, sizeof(echoPrompt), &bytesWritten);

    /* Loop forever echoing */
    while (1)
    {
        bytesRead = 0;
        while (bytesRead == 0)
        {
            status = UART2_read(uart, &input, 1, &bytesRead);

            if (status != UART2_STATUS_SUCCESS)
            {
                /* UART2_read() failed */
                while (1) {}
            }
        }

        bytesWritten = 0;
        while (bytesWritten == 0)
        {
            status = UART2_write(uart, &input, 1, &bytesWritten);

            if (status != UART2_STATUS_SUCCESS)
            {
                /* UART2_write() failed */
                while (1) {}
            }
        }
    }
}
when I test the demo, Why enter this function
void
PRCMDeepSleep(void)
{
    // Enable deep-sleep.
    HWREG(NVIC_SYS_CTRL) |= NVIC_SYS_CTRL_SLEEPDEEP;

    // Wait for an interrupt.
    CPUwfi();

    // Disable deep-sleep so that a future sleep will work correctly.
    HWREG(NVIC_SYS_CTRL) &= ~(NVIC_SYS_CTRL_SLEEPDEEP);
}

  • Hi !

    The reason why you enter this function can be determined by debugging your firmware. This can be done is CCS by moving step-by-step in your software, and seeing when are you getting blocked.

    In CCS 20, you can click on "Run > Debug Project" to flash and debug your project on your board. You will be allowed to step into functions and more, and you will see why are you jumping inside this function.

    Kind regards,
    Maxence

  • Hello

    This demo program does not call this function. Is there any default settings for this chip that are not set in the program?I found that after running while (1) in mainThread

  • Hi,

    The demo program may call this function through the drivers of the chip. This is something that may be difficult to find when only following function calls.
    For example, NoRTOS_start might initialize the power management driver, which may call the PRCMDeepSleep function.

    This is why debugging and stepping into your program, or setting a breakpoint in PRCMDeepSleep and watching the call stack is a good idea.

    Kind regards,
    Maxence

  •     #define PRCMDeepSleep                   NOROM_PRCMDeepSleep
    This is the only one in the entire file,and NOROM_PRCMDeepSleep dont found 
  • Hi !

    The example is not comprised of only one file but multiple source files that are added to your CCS project and other source files which are included when building. The reason why you enter the PRCMDeepSleep function is probably because your UART is blocking, which causes the system to go to sleep when you are waiting for UART data to read or send.

    If you run the debugger and stop at a breakpoint in the PRCMDeepSleep function, your call stack will likely be UART2_read -> UART2_readTimeout -> SemaphoreP_pend, and since no tasks are active then the idle function calls PowerCC26XX_standbyPolicy -> PRCMDeepSleep which is really just CPUwfi since UART2 read disables standby low power mode entry.

    Kind regards,
    Maxence

  • Hi

    Understanding is more complicated than I thought Thank you.