Strange Problems with MEGA.

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

Hi All.

I am having 2, probably related, problems on an Arduino MEGA.

My project is for a model railway so uses the LocoNet Library.   The project used lots of configuration data which I'm trying to upload to via the LocoNet from a PC.

For most part the code works but is never able to complete all 3744 bytes.  The point at which communications stops is very variable and I have not been able to track down why.

I am sure though that there is a bug somewhere.

After the serial communications stops it is possible to restart it.

The problem it that unplugging a device from the LocoNet and reconnecting it causes the Mega to reset.  Every time until after a power down cycle.

This seems like something in RAM has been corrupted or a stray pointer problem.

 

Is there a way to detect what might be causing the reset.  If I knew that I might be able to trace it back further to the actual bug.

I am using the BaseStream to capture the data from the PC.  I'm wondering if at one point something is writing past the end of the buffer.

 

I hope this makes sense to someone.

 

Regards

Wolf

 

Last Edited: Sat. Apr 4, 2020 - 08:06 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think you ate going to have to help is here a bit because apart from Torby I doubt anyone here knows what "Loconet" is. Are you talking about a bootloader.

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

clawson wrote:
I think you ate going to have to help is here a bit because apart from Torby I doubt anyone here knows what "Loconet" is. Are you talking about a bootloader.

 

It's not a bootloader, but a one wire communications network that uses 6 wires!

 

https://mrrwa.org/loconet-interf...

 

 

+14vdc ground switching so I am guessing not very high speed, but probably pretty reliable.

 

If there is an arduino library I would guess it's pretty stable, but hey you never know.

 

@Bigoldsofty,

Have you brought these questions to the Loconet community?  From a quick Google search there are many out there using this and with Arduino so you might find more support there than here.

 

Torby is our resident Model railroad x-pert.  I'll poke him and see if he's around

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

The PC is sending more data than the Arduino Mega can store in its internal SRAM.  If the application sketch needs to have random access to all 3744 bytes then you will need to add a Serial RAM chip to give the Arduino more storage space.

  Is the PC sending serial data to the Arduino on the same USART serial channel that is used by the Arduino's bootloader?  If so, then try a different USART.  There are four of them on the Arduino Mega. 

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

I thought that the mega2560 had 8k of RAM?

#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

Hi Jim

No, I haven't brought it up in the LocoNet community.

Mainly because every other LocoNet module I have made for my layout is behaving perfectly from the outset.

Well, once I had all the logic in the code right.

 

I came to this group because of the strange reset, as in re-starting from the setup function.  

I'm hoping that there is a way finding out where in my code I am triggering the reset.

Once I know that I can fix it.

 

Wolf.

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

The data is written to the EEPROM which is 4K.  

The PC request the read, and only after processing the response will it send the next request.

That makes the transfer slower that I would have liked but better safe than lose data.

Thankfully the device will rarely required reprogramming so the slower download should not be a problem.

LocoNet uses a soft UART.

 

Wolf

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

What do you have for "bypass" capacitors? First thing I'd try is like 47uF between + and ground.

If you don't know my whole story, keep your mouth shut.

If you know my whole story, you're an accomplice. Keep your mouth shut. 

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

It is a standard off the shelf MEGA so I'm not sure about the caps.

 

I solved the problem last night after lots of searching.

The was a call to a null point to a function in one of the libraries.

The pointer wasn't checked prior to the call.

I have informed the author of the library who will update it.

 

At least the MPU reset unlike some years ago there was one MPU I used back then which had an opcode a few us named 'Overheat and selfdistruct'.

You could actually see it glow through the quarts window over the chip.

 

Cheers

Wolf