i've this strange behaviour and I can't figure it out why.
I've already used this library before and so I can't understand why I've so many trouble now, but basically I can't receive any interrupt when receiving a Modbus frame from the master.
I've configured my device as a slave with the following parameters:
/* Modbus Slave initialization */
modH->uModbusType = MB_SLAVE;
modH->port = &huart3; // This is the UART port connected to STLINK in the discovery F429
modH->u8id = 1; //Master ID
modH->u16timeOut = 1000;
modH->EN_Port = UART3_TX_EN_GPIO_Port; // RS485 Enable
modH->EN_Pin = UART3_TX_EN_Pin; // RS485 Enable
modH->u16regs = ModbusDATARX;
modH->u16regsize= sizeof(ModbusDATARX)/sizeof(ModbusDATARX[0]);
modH->xTypeHW = USART_HW;
static void MX_UART3_Init(void)
{
/* USER CODE BEGIN UART3_Init 0 */
/* USER CODE END UART3_Init 0 */
/* USER CODE BEGIN UART3_Init 1 */
/* USER CODE END UART3_Init 1 */
huart3.Instance = UART3;
huart3.Init.BaudRate = 38400;
huart3.Init.WordLength = UART_WORDLENGTH_8B;
huart3.Init.StopBits = UART_STOPBITS_1;
huart3.Init.Parity = UART_PARITY_NONE;
huart3.Init.Mode = UART_MODE_TX_RX;
huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart3.Init.OverSampling = UART_OVERSAMPLING_16;
if (HAL_UART_Init(&huart3) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN UART3_Init 2 */
/* USER CODE END UART3_Init 2 */
}
I'm putting a brekpoint here when I send messages though QModBus tool but it's never reached
void UART3_IRQHandler(void)
{
/* USER CODE BEGIN UART3_IRQn 0 */
/* USER CODE END UART3_IRQn 0 */
HAL_UART_IRQHandler(&huart3);
/* USER CODE BEGIN UART3_IRQn 1 */
/* USER CODE END UART3_IRQn 1 */
}
Hi, the setup seems right. The issue is quite general and not related to the library, at all.
Besides that, you should test the serial port interrupt even before adding the library.
Also check the RTOS is running.
Hi,
i've this strange behaviour and I can't figure it out why.
I've already used this library before and so I can't understand why I've so many trouble now, but basically I can't receive any interrupt when receiving a Modbus frame from the master.
I've configured my device as a slave with the following parameters:
My GPIOs are set in this way:
And the interrupt is this way:
And the uart is set in this way:
I'm putting a brekpoint here when I send messages though QModBus tool but it's never reached
What I'm missing?
Thanks in advance for any help