View previous topic :: View next topic |
Author |
Message |
dmitrboristuk
Joined: 26 Sep 2020 Posts: 55
|
Using external RAM for data exchange between two MC (8 bit) |
Posted: Wed Sep 04, 2024 3:52 am |
|
|
Hello. There is one microcontroller with a program with a large number of interrupts. The organization of data exchange using MODBUS is very complex, especially when packets up to 30 bytes are transmitted and received. Disabling interrupts during transmission is not allowed, because it will lead to the crash of the main program flow. There are ideas to organize data exchange via external RAM, to which access from two microcontrollers can be organized. Ideally, I found a CAT24C208 microcircuit with dual access, but it is better to do it on the more common PCF8570 (or newer). My question is how to organize arbitration between microcontrollers during memory access. But maybe there are other solutions. I would like to get information and see examples of program code. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19495
|
|
Posted: Wed Sep 04, 2024 7:53 am |
|
|
So much here depends on the speed you actually need.
Understand, you can use quite conventional RAM, provided neither
microcontroller accesses at the same time, and your data writes/reads
are structured so that each device can tell when a packet is complete.
You just use a slow external clock, and only perform the access from
controller #1 on the low half cycle of this, with the other on the high
half cycle. Provided each transaction can complete in the half cycle, no
problem.
The easiest/fastest/best way, is just to use dual port RAM. Look at
something like the Renesas chips:
[url]
https://www.renesas.com/us/en/products/memory-logic/multi-port-memory/asynchronous-dual-port-rams?gad_source=1
[/url]
Normally you'd use either a busy line, or have once chip operate a
semaphore to give synchronisation. |
|
|
dmitrboristuk
Joined: 26 Sep 2020 Posts: 55
|
|
Posted: Wed Sep 04, 2024 1:14 pm |
|
|
Ttelmah Thank you for your answer, I will try to do it this way. But first I want to try to run a request from a short interrupt procedure on the Master I2C device to read/write the memory of the Slave device. I want to use the Slave port output as a "hard semaphore". How do you like this idea? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19495
|
|
Posted: Thu Sep 05, 2024 6:31 am |
|
|
It sounds as if you are talking quite a slow link. So an I2C memory, and
a simple semaphore. You can do a semaphore by wiring a wire for 'wire OR'
operation. Single wire, pull up resistor, and each device only drives the
line low or lets it float. You do have a slight complexity if both devices
can control the line, of handling when both try to start at the same time,
but it only one device controls this, and the slave always does it's
transaction soon after the line is operated by the master, this can work. |
|
|
|