Hello everyone!
I'm having a strange problem with the arduino; I'm very new to electronics, so please bear with me.
I've isolated the problem to the following:
Since the 'long' in arduino is 32bits long, the output should be "1000\n1000000\n\n", correct? The problem is, my serial port reads "1000\n0\n\n" :-?
However, if i change the line
long a=param;
to
long a=1000L
,I get the expected "1000\n1000000\n\n"
Thanks for your reply, mikalhart.
I feared that.
This was initially a simple project to "simulate" PWM in all the digital pins; While it worked, I was having strange timing bugs, so I stripped it to the code I posted, trying to isolate the problem.
Is there any chance this could be a problem with the hardware/board design? I'm using a seeeduino http://www.seeedstudio.com/blog/?page_id=110. Since it uses the same atmega168, I'd expect the computations to match :-/
Ok it seems this is not a hardware problem after all. After a suggestion from seeedstudio.com, I've tried out different versions of the IDE;
compiling in IDE version 12 (linux), the one I was using, the serial port spits "1000\n0\n\n"
In version 11 (and some older), the result is "1000\n-64330000\n\n".
However, if I compile it in Windows, the result is exactly the expected, "1000\n1000000\n\n" :-?
I'm pretty sure there's no problem with the ttyUSB, as I've tried reading the windows-compiled version in the linux IDE port monitor, and it still gives "1000\n1000000\n\n"
Can this be a bug on the linux IDE?
I'm using Ubuntu 8.10, gcc-avr package 1:4.3.0-2