I am using atmega 2560 as main(master) controller and other 5 salve 2 atmega 8 and 3 atmega 328p, there is two device with analogue output connected to main controller atmega 2560 through ads1115 module ,ads1115 converts analogue signal into 16 bit digital data and give it to atmega 2560 via I2C,

also the main controller has serial communication with pc and I2C comm. with salves. and some motors are also connected with controllers.

Now, My issue is that there is one function which reads the data from ads1115 for fix instances and with fix time interval and prints it. for running code for some time lets say 4-5 hour , controller hangs in between that function. and after that no serial communication work. i have to switch of supply to restart the machine.

  • We cannot answer this without your code. Please provide a mininal working example, that shows the observed behavior. – chrisl Jun 15 '19 at 13:04
  • do you use String class? – Juraj Jun 15 '19 at 13:52

It's hard to say anything for sure without seeing the code, but for a program that freezes using I2C communication, I would seriously suspect the Wire library. This library has a few loops here and there where it waits for a specific condition on the bus, with no timeout. See twi.c. If, for whatever reason, the condition never happens, then the program is stuck in the infinite wait.

You could try finding al alternative I2C library or, if you can tolerate the occasional crashes, enable the watchdog in order to get out of the freezes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.