Leonardo UART not receiving depending on upload computer used

This is a very strange problem. I understand the Leonardo's UART is on Serial1, that USB is implemented with code rather than a dedicated chip, etc. I understand that uploads to the Leonardo may sometimes require holding down the reset button then releasing it when the IDE notes it is uploading.

In fact my code actually works fine. At least it does when uploaded from my late 2008 MacBook Pro. But when the same code is uploaded from my newer late 2013 MacBook Pro the code runs…but Serial1 never sees its input. I've tried this with a number of Leonardo boards and the behavior is the same.

To be clear both computers upload using USB. I'm talking about incoming pin 0 serial data not being seen by the application when it runs.

The only unusual thing the code does is use the DMXSimple library. I understand it uses Timer2, but I'm not sure how that could cause the same code to work when uploaded from one computer but not the other.

I suppose it's possible that the Arduino software itself is configured differently on the two computers. I've used Arduino 1.0.1 on both to try to minimize that.

Any ideas?



p.s. There's a lot of code involved so that's why I didn't upload it. In that it works from one uploader but not the other I'm not sure that would help much. I could write a small program and see if it behaves the same way I suppose. I could also switch to using a software serial pin I suppose…but I really wanted the advantage of using the UART.

If they are both running Arduino 1.0.1 (I would switch to 1.0.5) the only differences I can think of are the USB hardware and the Java version. Make sure both are updates to the latest version of Java?

Are you using PROGMEM for anything? There was a problem reported recently where a program using a table in PROGMEM was getting different results when compiled on Mac than when compiled on Linux. That should not be the case when both are Mac and both use the same avrgcc compiler.

I am using PROGMEM but both computers involved are Macs. The newer Mac could well be using a different version of the C compiler I suppose.

I'm going to go back and carefully compare the differences between the two machines. It may be that I'm using a variant of DMXSimple on the one and not the other. I have a version that uses TIMER3 and perhaps TIMER2 has some kind of interaction with the UART. Just not sure.

If I do figure this out I'll be sure to post here. It will be a drag to have to keep the old Mac merely because it's the one that can upload properly to the Leonardo.

Well, as these things often are, this was kind of dumb. I understood Timer2 was used by DMXSimple, but what I didn't appreciate was that on the Leonardo's microcontroller chip Timer2 is used to provide the timebase for the UART. This is unlike other Arduinos.

So in my case DMXSimple was taking over Timer2, with the result that DMXSimple worked just fine, but serial communications on pins 0 and 1 stopped working.

So why did it work when I did the Leonardo uploads from my older Mac? Well, what I had forgotten was that 2 years ago someone shared with me a version of DMXSimple modified to use a different timer when compiled for the Leonardo. As soon as I put that version into the libraries folder on my new Mac everything worked just fine.

Bottom line: if you use DMXSimple on a Leonardo it will probably knock out Serial1 and may have weird interactions with anything else using Timer2. Or, if something else grabs Timer2, DMXSimple itself will likely fail.