2019-09-12 8:56 AM
Using CubeMX v5.3.0 to generate IrDA on USART2 at both 115200 and 9600 baud doesn't seem to work. I have enabled both the interrupt and DMA in CubeMX and left both pins pulled high. The generated code was then opened in Keil uVision V5.28.0.0 where I added the following:
/* USER CODE BEGIN 0 */
uint8_t myTxData[24] = "Initialize done\r\n...\n";
uint8_t myRxData_irda[1];
/* USER CODE END 0 */
/* USER CODE BEGIN 2 */
HAL_IRDA_Receive_DMA(&hirda2, myRxData_irda, 1);
...
...
...
HAL_IRDA_Transmit(&hirda2, myTxData,sizeof(myTxData),100);
/* USER CODE END 2 */
/* USER CODE BEGIN 4 */
void HAL_IRDA_RxCpltCallback(IRDA_HandleTypeDef *hirda)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(hirda);
/* NOTE : This function should not be modified, when the callback is needed,
the HAL_UART_RxCpltCallback can be implemented in the user file.
*/
HAL_UART_Transmit(&huart1, myRxData_irda,1,10);
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
}
/* USER CODE END 4 */
I hooked up the IR emitter to PA2 (USART2_TX) and the IR Receiver to PA3 (USART2_RX) but have no luck reading a response in debug or on UART1.
Currently using a custom board and the STM32L0538-DISC0 dev board and problem persists on both.
Any help would be much appreciated.