RS485 example for at tiny 3216 #1218
-
|
Hello all! Trying to test the RS485 between two attiny3216, but no example around ? Connecting the ST4E1216 part. The pin RXD and TXD, 6 and 7 pin are respectively connected to the R and D of the transceiver, however, I am not sure to what pins should the RE and DE (enable) be connected to? Since the ST4e1216 has automatic direction control, therefore, I guess may be relevant? Printed out the pins of the serial: What are these numbers? Thought I would find those number in the Port Function Multiplexing, but nothing... Any ideas? Indeed, it would be much easier to start with an example, do we have one where I can find more information how to get going ? Any comments, etc. are more than welcome! Best. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 17 replies
-
|
That library is likely not compatible with megatinycore. You might be able to ask them to add support. No need for a library here, it's just serial communication with an additional pin to assert while transmitting. Typically you tie DE and /RE together and to a gpio. Then before you transmit serial, set it high and pull it low when you are done. The proper way would be to wait until serial buffer is empty before pulling the pin low. You can use Serial.availableForWrite() to check. If you want to be able to check for collision, then don't tie /RE to DE, just pull /RE to ground and leave it there. Then you will read back everything you transmit. Then you have to compare what was sent to what was received to determine collision. Usually a good idea for multi-drop. Should not be needed for just 2 devices, if the other device has good manners. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
OK, finally got to the end, it actually works! In my case, the trick was in manually setting the /RE, DE, and the Serial.flush(). But, there are still questions :
|
Beta Was this translation helpful? Give feedback.



Or if you want to print to two serial devices on a part with one UART use an alternating schedule.