Connect two mega's not by USART

Go To Last Post
24 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I planing to build new circuit board with two chips: ATmega16 + ATmega328P and establish connection between them by USART.

But I planing to use ESP8266 WiFi module (it working with USART only).

So my question is...how I should connect ATmega16 + ATmega328P without USART?

I2C - keep only for external modules (such as DS18B20 or other). SPI - for programator use.

...or I should consider to use some new WiFi modules (for example with 1-Wire interface or other interfaces but not USART witch I do not know about)???

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Darien wrote:
SPI - for programator use.
Nothing says that you cannot use it both for programming and also CPU-CPU connection. Just make sure to use slave selects and isolate ISP from the rest as shown in the datasheet

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Instead of using two AVR's, use one larger one, like a M2560!

It will have multiple USARTs, TWIs, and SPIs.

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:

Instead of using two AVR's, use one larger one, like a M2560!

It will have multiple USARTs, TWIs, and SPIs.

 

Jim

 

I guess I no need such powerful chip. I will write separate prog for each chip:

1. modules and external circuits (buttons, LED, et.)

2. NET prog (chip connected to ENC28J60) ETHERNET logic.

I try to split device into two pats:

1. ETHENET logic

2. All other (modules, buttons, LEDS, LCD)

Last Edited: Mon. May 20, 2019 - 01:16 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

Darien wrote:
SPI - for programator use.
Nothing says that you cannot use it both for programming and also CPU-CPU connection. Just make sure to use slave selects and isolate ISP from the rest as shown in the datasheet

 

Master-Slave logic. I try to avoid it. I try to build master-master communications. I guess if needed I will connect to chips other devices with this login (master-slave)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Darien wrote:
Master-Slave logic. I try to avoid it.
Then why are you talking about Wi-fi as a potential link? That's going to involve running a server and a client too ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

Darien wrote:
Master-Slave logic. I try to avoid it.
Then why are you talking about Wi-fi as a potential link? That's going to involve running a server and a client too ?

 

WiFi for communications with other devices.

Two chips (ATmega16 + ATmega328P) must act as single device (system).

I try to split tasks by chips and if needed chips will communicate via USART.

WiFi module will be connected to one chip only! and connect to other devices.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is this a school/University project assignment then? In the real world professional engineers strive to put all functionality into a single chip where possible as splitting a design is usually the worst thing imaginable for all kinds of reasons.
.
As suggested above a single 64/128/256K chip with plenty of IO is a much better idea than multiple 32K chips.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

See this topic...

 

https://www.avrfreaks.net/commen...

 

...and have a read of DN_035.

 

Then have a read of AVR042 on how to share SPI lines.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Is this a school/University project assignment then? In the real world professional engineers strive to put all functionality into a single chip where possible as splitting a design is usually the worst thing imaginable for all kinds of reasons.

 

While it's generally true, I see at least one plausible use case for hardware separation of tasks: run hard real time tasks on one device, reducing codebase as hard as possible to have ultimate reliability of core tasks, and use second chip for rich communication / configuration / utilities / whatever don't have to be hard real time and where reliability is not so crucial, using convenient 3rd party libraries and easy-to-develop code.

Have both efficient implementation and comprehensive source code for peripherals configuration with my library: https://github.com/ichthuss/opti_init

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ichthuss wrote:
and use second chip for rich communication / configuration / utilities / whatever don't have to be hard real time
Yeah but that is usually done simply by a split of interrupts (time critical) and main() loop (the rest). If you do split it between micros then you now face other issues like time synchronisation between the two not to mention the small detail that code changes may now involve both micros which opens up the can of worms of ensuring that two sets of firmware are in step, etc etc

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That's right, but interrupts may be disabled, or time-critical processes logic may happen to be way too complicated to be implemented as ISR without disruption of other code, which still leaves some rare use cases for a setup mentioned. That said, typically drawbacks that you named are more important, and one-MCU solution is better.

Have both efficient implementation and comprehensive source code for peripherals configuration with my library: https://github.com/ichthuss/opti_init

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Master-Slave logic. I try to avoid it. 

That's ridiculous.   Master-master will  usually be a much bigger headache...who is in charge when something is going wrong?...lots of fun debugging.  Why would you put yourself through this?  Why would both need to be the master?

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Is this a school/University project assignment then? In the real world professional engineers strive to put all functionality into a single chip where possible as splitting a design is usually the worst thing imaginable for all kinds of reasons. . As suggested above a single 64/128/256K chip with plenty of IO is a much better idea than multiple 32K chips.

 

That is probably true. I guess better should be design circuit board on one powerful chip like M2560.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ichthuss wrote:

clawson wrote:
Is this a school/University project assignment then? In the real world professional engineers strive to put all functionality into a single chip where possible as splitting a design is usually the worst thing imaginable for all kinds of reasons.

 

While it's generally true, I see at least one plausible use case for hardware separation of tasks: run hard real time tasks on one device, reducing codebase as hard as possible to have ultimate reliability of core tasks, and use second chip for rich communication / configuration / utilities / whatever don't have to be hard real time and where reliability is not so crucial, using convenient 3rd party libraries and easy-to-develop code.

Yes. That was my idea.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So if I should switch from using two chips on one board solution to one powerful chip on board... there is some boards on market available?? But not Arduino boards ...I do not like Arduino IDE. I prefer to write clean C code on AtmelStudio7.2^

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Darien wrote:
But not Arduino boards ...I do not like Arduino IDE.
You can use the (excellent!) board without the IDE. You don't even have to use avrdude and bottloader if you don't want to (though it's a well engineered solution too). The Arduino boards represent incredible value for money and are well engineered. Program them separately in Asm, Basic, C or whatever you choose. Clearly an Arduino Mega pretty much delivers exactly what you require.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

clawson wrote:

Darien wrote:
But not Arduino boards ...I do not like Arduino IDE.
Clearly an Arduino Mega pretty much delivers exactly what you require.

+1000

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Or use an esp32 which is a far superior chip to the esp8266 and do most of the work on it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

valusoft wrote:

clawson wrote:

Darien wrote:
But not Arduino boards ...I do not like Arduino IDE.
Clearly an Arduino Mega pretty much delivers exactly what you require.

+1000

 

I guess I copy ArduinoMEGA board but without USB-chip for IDE.

I no need this circuits on board... instead of USB-IDE-chip I implement something useful for my project 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why not just buy an Arduino Mega then simply ignore the USB/UART link ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I now look into some other chips. I don't know that ATmega1281 has 4 USART pins: 2 lines (RxD pin + TxD pin)... that is useful. That is perfectly match my tech spec. I would use this chip instead (ATmega16 + ATmega328P on one boad).

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Darien wrote:
I don't know that ATmega1281 has 4 USART pins: 2 lines (RxD pin + TxD pin)... that is useful.
mega1280

The follow-on to mega1280 is XMEGA128A1U if able to power the MCU at 3V.

ATmega1280 - 8-bit AVR Microcontrollers

ATxmega128A1U - 8-bit AVR Microcontrollers (8 USART)

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gchapman wrote:

Darien wrote:
I don't know that ATmega1281 has 4 USART pins: 2 lines (RxD pin + TxD pin)... that is useful.
mega1280

The follow-on to mega1280 is XMEGA128A1U if able to power the MCU at 3V.

ATmega1280 - 8-bit AVR Microcontrollers

ATxmega128A1U - 8-bit AVR Microcontrollers (8 USART)

 

 

Thanks) I already review this docs...I think I will start with 64-pin chip ATmega1281. If necessary I will switch to more powerful chip.