2018-11-29 11:27 AM
My UART works well in normal mode, but when I want to analyze callbacks for Rx in debug mode it doesn't work properly. I mean when I set breakpoint at HAL_UART_RxCpltCallback and I'will send bytes from terminal, debugger stops at this callback and doesn't perform appropriate amount of calls. This is my code:
#define BUFF_SIZE 255
char BUFF_RX[BUFF_SIZE];
__IO uint8_t BUSY_RX = 0;
__IO uint8_t EMPTY_RX = 0;
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) {
if(huart == &huart2) {
EMPTY_RX++;
if(EMPTY_RX >= BUFF_SIZE)
EMPTY_RX = 0;
HAL_UART_Receive_IT(&huart2, (uint8_t *)&BUFF_RX[EMPTY_RX], 1);
}
}
int main() {
/* CubeMX initializations etc */
HAL_UART_Receive_IT(&huart2, (uint8_t *)&BUFF_RX[0], 1);
}
Steps:
For this operation i send 4 bytes.
2018-11-29 12:31 PM
Real time systems don't function well when stopped.
Make sure the USART isn't flagging errors (overrun, etc) as a result of you stopping things.
The debugger will damage the USART state if you inspect it. ie showing you DR clears SR.RXNE.
Try to debug in ways that doesn't require human interaction.
2018-11-29 01:18 PM
I think even running with a debugger is slower than running free. So I miss bytes.
Try Arduino mode debugging. Use flags and print " I am here at #12775"