Skip to content

Adding communication modules : RS485 and synchronization

Ayoub Farah Hassan requested to merge afarahhass/core:PR_CommSynchroRS485 into main


Using syncCommunication.initMaster() starts a board in master mode, and send a synchronization pulse every control task period. Using syncCommunication.initSlave() starts a board in slave mode, and the control task is called only when receiving a synchronization pulse from master allowing us to have two synchronized control task working at the same time.

How it works

The synchronization is a feature from HRTIM (see RM0440 27.3.19) which synchronize multiple HRTIM between them. In this commit, in master mode, when HRTIM TIMA resets the HRTIM is sending a synchronization pulse via PB1 which means that if TIMA is working at 200Khz it sends a pulse every 5µs. However this is only true if PB1 is in alternate mode. What we are doing is :

  • PB1 in output mode which force it to low level.
  • When we enter in the control task, we set PB1in alternate mode.
  • Then we wait for about 5µs in order to send a single synchronization pulse before forcing again PB1 to low level by setting it to output mode.

We are not only synchronizing control task, but also master and slave HRTIM and PWM with this.


This commit also implement modules for communication with RS485 :

  • DMA 1 channel 6 is used for transferring data buffer to send to USART3 TX, and channel 7 is used for retrieving data buffer from USART RX.
  • RS485 Driver Enable mode is used (see RM0440 37.5.20)

Merge request reports