modbus with RS_485 communication
HI, i am using RS_485 as a serial communicator with modbus in stm32f103. But i am confused with TXEN pin used in Rs_485. i have read information it is used as transmitter and receiver . when transmitting the pin is set to high . while receiving it should be set to low. but i am confused how to write a code for it and where to use it . can anyone help me with it please.
HAL_GPIO_writePin(GPIO_PORT, rs_485_txen_Pin, GPIO_SET) // while Transmitting.
HAL_GPIO_writePin(GPIO_PORT, rs_485_txen_Pin, GPIO_RESET) // while Receiving.
i have written like this . is this valid code or should i add still or not. and in which part this code should be wriiten like before using HAL_UART_ Transmit() and HAL_UART_Receive() or can i use anywhere in my code. can anyone help me with please . if i need to add let me know what i need to add.
Thank you
