modelI2cIrq

I2C between two microcontrollers: B answers the commands of A from an I2CTarget IRQ handler

Extends from Modelica.Icons.Example (Icon for runnable examples).

Information

Same electrical I2C bus as Examples.MultiMcu.I2c, but board B (i2c_target_irq.py) answers commands from an IRQ handler instead of exposing a memory. Board A (i2c_controller_irq.py) writes a command, then reads the reply: ID gives MCU-B, CNT gives the number of commands received so far.

In the handler of B, IRQ_END_WRITE means that the command is complete (B reads it with readinto()), and IRQ_READ_REQ that the controller wants a byte while none is queued (B queues the reply with write()). The handler runs at the same simulated instant as the event: the reply is sent at once, without the clock stretching that a real target would need. A sets its GP7 high if the three replies are right.

Components

TypeNameDefaultDescription
MCUmcuAController: Resources/Scripts/MCU/i2c_controller_irq.py (SCL = GP4, SDA = GP5)
MCUmcuBTarget at 0x43: Resources/Scripts/MCU/i2c_target_irq.py (SCL = GP4, SDA = GP5)
Modelica.Electrical.Analog.Basic.Groundground
Modelica.Electrical.Analog.Sources.ConstantVoltagevdd3.3 V supply of the pull-up resistors
Modelica.Electrical.Analog.Basic.ResistorpullSclpull-up of SCL: an I2C bus only rises through its pull-ups
Modelica.Electrical.Analog.Basic.ResistorpullSdapull-up of SDA