AnsweredAssumed Answered

UART stm32f4

Question asked by s.b.004 on Sep 25, 2015
Latest reply on Oct 1, 2015 by Amel N
Hello, I'm trying to run rs485 using transceiver sn65hvd11, and two 2 stm32f4. The first is a master, second is a slave. The problem is that I cant run the communication between the two devices. This is the code
while (!(GPIO_PIN_RESET == HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_0))); // While I didnt press the button comunication didnt start
 
  while (1)
  {
   
        HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_12); // LED is blink
        HAL_Delay(200);
 
 
        strln = sprintf(temp_msg,"\n-----------------------------------------------------------------\n\n");
        HAL_UART_Transmit(&huart1,(uint8_t *)&temp_msg,strln,200); // transmit to PC if there is a problem with transmiting
         
             
/*=================================
        Slave
===================================*/
//RESET = 0; SET=1;
      HAL_GPIO_WritePin(GPIOA,GPIO_PIN_7,GPIO_PIN_RESET );//DE
        HAL_GPIO_WritePin(GPIOC,GPIO_PIN_7,GPIO_PIN_RESET );//RE
         
        while (HAL_OK == HAL_UART_Receive(&huart3,(uint8_t *)&transmite_msg_translator,sizeof(transmite_msg_translator),200))
        {
                 
                HAL_GPIO_WritePin(GPIOA,GPIO_PIN_7,GPIO_PIN_SET );
                HAL_GPIO_WritePin(GPIOC,GPIO_PIN_7,GPIO_PIN_SET );
                     
              HAL_UART_Transmit(&huart3,(uint8_t *)&transmite_msg_translator,sizeof(transmite_msg_translator),200);
        break;
        }
/*=================================
    END Slave
===================================*/          
         
/*=================================
        Master
===================================*/
     
     
                HAL_GPIO_WritePin(GPIOA,GPIO_PIN_7,GPIO_PIN_SET );
                HAL_GPIO_WritePin(GPIOC,GPIO_PIN_7,GPIO_PIN_SET );
                HAL_UART_Transmit(&huart3,(uint8_t *)&transmite_msg_translator,sizeof(transmite_msg_translator),200);
         
 
        HAL_GPIO_WritePin(GPIOA,GPIO_PIN_7,GPIO_PIN_RESET );
        HAL_GPIO_WritePin(GPIOC,GPIO_PIN_7,GPIO_PIN_RESET );
             
         
         if (HAL_OK == HAL_UART_Receive(&huart3,(uint8_t *)&transmite_msg_translator,sizeof(transmite_msg_translator),200))
        {
     
            HAL_GPIO_WritePin(GPIOA,GPIO_PIN_7,GPIO_PIN_SET );
                HAL_GPIO_WritePin(GPIOC,GPIO_PIN_7,GPIO_PIN_SET );
             
            HAL_UART_Transmit(&huart3,(uint8_t *)&transmite_msg_translator,sizeof(transmite_msg_translator),200);
             
 
        }
         
            else
            {  
                     
                HAL_UART_Transmit(&huart1,(uint8_t *)&warning_msg_translator,sizeof(warning_msg_translator),200);
             
            }
/*=================================
END Master
===================================*/
        }}

Outcomes