19th May 2021
The I2C interface interrupts can be used to synchronize the time on two (or more) microcontrollers. An event that occurs almost simultaneously on both processors is the start of an I2C interrupt, eg "SLA + W sent and ACK received" on master and "SLA + W received, ACK returned" on slave.
Tests were carried out on two AVR Atmega88PA processors with a 16MHz clock. The following image shows the rising edges of the signal set at the beginning of the interrupt routine. The time difference between the two CPUs is approximately 260ns.
*.prj files are project files for VMLab (ver. 3.15) simulation.
AVR fuses can be set in make command (see makefile).
- avr-gcc
- avr-libc
- AVR Atmega88PA - documentation
- I2C - info
- I2C - specification and user manual (NXP)
This project is licensed under the MIT License.
- Krzysztof Zurek - github