STM32C011F4P6: transparent USART1 / USART2 transceiver
I'd like to use an STM32C011F4P6 as a transceiver between USARTs 1 and 2.
As a first approach, I've set both USARTs to 9600bd, and I want anything that's incoming on one of them to be directly sent to the other. In both directions at the same time.
In the USART1 and USART2 configuration I enabled NVIC interrupts for both of them.
I then created a HAL_UART_RxCpltCallback() in section 4 in my main.c:
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
/* Prevent unused argument(s) compilation warning */
//UNUSED(huart);
if (huart->Instance == USART1) {
HAL_UART_Transmit_IT(&huart2, huart1.pRxBuffPtr, 1);
HAL_UART_Receive_IT(&huart1, huart1.pRxBuffPtr, 1);
} else if (huart->Instance == USART2) {
HAL_UART_Transmit_IT(&huart1, huart2.pRxBuffPtr, 1);
HAL_UART_Receive_IT(&huart2, huart2.pRxBuffPtr, 1);
}
/* NOTE : This function should not be modified, when the callback is needed,
the HAL_UART_RxCpltCallback can be implemented in the user file.
*/
}
I know this is a very naïve approach, however this is a first test, just to get things working.
in my main() I've enabled receive interrupts like so:
HAL_UART_Receive_IT(&huart1, huart1.pRxBuffPtr, 1);
HAL_UART_Receive_IT(&huart2, huart2.pRxBuffPtr, 1);
This happens right before the endless-while-loop, the rest of the code was generated by the IDE.
Now here's my problem: the callback function HAL_UART_RxCpltCallback() is never called! I've set breakpoints in there and used SWD to debug the code, but either the interrupt never occurs, or for some reason the function is never called, I don't know what I'm doing wrong here...
Can anyone help me out?
I'll be happy to provide additional information in case it's unclear what I'm trying to accomplish or how my setup looks, but I'm unsure what I additional info I should provide.
Thanks in advance!
--polemon
