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

STM32 USART debuging

Hello everyone,

I would be very gratefull if you help me with this or give me some idea. I have problem with STM32100RbB USART module. It uses Cortex M3.

The USART uses hardware flow control (RTS/CTS). When I start debugging and try to read data in USART registers it is always different scenario. Data deepends on where I put breakpoints!

For example, if I put breakpoint just before function that reads data register and after that press RUN to instruction for reading register the data is correct, but if I press RUN just after reset and go directly to this instruction data is corrupted....

Did anyone had similar problems and can give me some ideas? I tought it is timing problem so I put delays everywhere I could, but it didn't help.

Thank you,
Nikola

Parents
  • As Andrew notes - don't try to use the debugger to look at magical hardware registers that has "read-once" properties and then expect your code to later be able to read the same value.

    Or expect the code to read from the "read-once" register and then expect the debugger to also see the same value.

    A number of UART registers has the property that reading the register clears internal UART state. If you read out a received character, then the RX register will prepare for the next received character instead. If you read from some of the status registers, you may see error flags and these error flags may be automatically reset on read.

    Write your code so that you assign the UART register value to a variable. Then have your code look at the contents of this variable to decide what to do next. This allows you to set a breakpoint and look at that variable without affecting any internal UART state.

Reply
  • As Andrew notes - don't try to use the debugger to look at magical hardware registers that has "read-once" properties and then expect your code to later be able to read the same value.

    Or expect the code to read from the "read-once" register and then expect the debugger to also see the same value.

    A number of UART registers has the property that reading the register clears internal UART state. If you read out a received character, then the RX register will prepare for the next received character instead. If you read from some of the status registers, you may see error flags and these error flags may be automatically reset on read.

    Write your code so that you assign the UART register value to a variable. Then have your code look at the contents of this variable to decide what to do next. This allows you to set a breakpoint and look at that variable without affecting any internal UART state.

Children