This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

STM32F Sleep Mode

Hello,

I am having trouble entering sleep mode with the STM32F103 and RL-RTX. I am expecting the processor to halt indefinitely when I call the following code:

printf("calling __WFI();\r\n");
// enter low power mode: Request Wait For System Interrupt to wake uC up
__wfi();
printf("Exiting sleep mode\r\n");

The problem is that after "__wfi();" is called is automatically goes to the next statement: "printf("Exiting sleep mode\r\n");".

It almost seems like something is waking the processor from sleep mode right away or it is not going into sleep.

I would expect that the CPU halts at __wfi() until an interrupt is triggered.

Parents Reply Children
  • The UART is polled. It is taken from the example of Retarget.c

    int sendchar (int c) {
    
      if (c == '\n')  {
        while (!(USARTx->SR & USART_FLAG_TXE));
        USARTx->DR = 0x0D;
      }
      while (!(USARTx->SR & USART_FLAG_TXE));
      USARTx->DR = (c & 0x1FF);
    
      return (c);
    }
    

    This basically means that the __WFI(); instruction will not get called until all characters are sent out.