Hello
I am implementing wireless communication with STM32F407 and XBEE S2C module, but I have a problem and would like to ask a question.
What we want to implement is to connect two STM32F407 and two XBEE S2C modules to each other to send/receive and perform bidirectional communication.
Therefore, XBEE wireless communication is connected with STM32F407 via UART wired communication, so first connect two STM32F407 devices by UART wired communication to match the two-way transmit/receive test.
So, to communicate wirelessly with XBEE, I made 2 sets by connecting STM32F407 and XBEE module with UART communication. And I put the program source code used for wired communication and tested it, but it doesn’t work unlike wired communication.
To find the cause, I took a picture of the TX and RX of the XBEE with an oscilloscope. And it was confirmed that the XBEE module also uses the XCUT program to enable bidirectional communication.
Are there any issues that need to be configured separately?
Below is the program source code.
MCU1
uint8_t a = 0;
uint8_t b = 0;
while (1)
{
if(HAL_GPIO_ReadPin(GPIOE, GPIO_PIN_3) == GPIO_PIN_SET)//송신 코드
{
a = 1;
HAL_UART_Transmit(&huart3, &a, 1, 10);
}
if(HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_15) == GPIO_PIN_SET)//송신 코드
{
a = 2;
HAL_UART_Transmit(&huart3, &a, 1, 10);
}
if(HAL_UART_Receive(&huart3, &b, 1, 10) == HAL_OK)//수신 코드
{
if(b == 1)
{
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_12, GPIO_PIN_RESET);
}
if(b == 2)
{
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_13, GPIO_PIN_RESET);
}
}
else//초기화
{
a = 0;
b = 0;
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_13, GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_12, GPIO_PIN_SET);
}
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
MCU2
uint8_t a = 0;
uint8_t b = 0;
while (1)
{
if(HAL_GPIO_ReadPin(GPIOE, GPIO_PIN_15) == GPIO_PIN_SET)//송신 코드
{
b = 1;
HAL_UART_Transmit(&huart3, &b, 1, 10);
}
if(HAL_GPIO_ReadPin(GPIOE, GPIO_PIN_13) == GPIO_PIN_SET)//송신 코드
{
b = 2;
HAL_UART_Transmit(&huart3, &b, 1, 10);
}
if(HAL_UART_Receive(&huart3, &a, 1, 10) == HAL_OK)// 수신 코드
{
if(a==1)
{
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_RESET);
}
if(a==2)
{
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_14, GPIO_PIN_RESET);
}
}
else//초기화
{
a = 0;
b = 0;
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_14, GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_SET);
}
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}