jd-shah / arduino-tiny

Automatically exported from code.google.com/p/arduino-tiny
Other
0 stars 0 forks source link

Serial debug garbage at 8mhz (attiny85) #23

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Running the following sketch at 8mhz (internal clock) will produce garbage on 
the serial output:

void setup() {
  Serial.begin(9600);
}

void loop() {
  delay(1000);
  Serial.println("hello world!");
}

At a 1mhz clock this code works fine. Is this due to out of spec attiny's? I 
tested with 5 seperate attiny's. Or, am I missing something crucial here?
What can I do to troubleshoot this issue?

Original issue reported on code.google.com by m.da...@gmail.com on 18 Oct 2011 at 9:12

GoogleCodeExporter commented 8 years ago
Has the processor been tuned?

How did you change the processor to run at 8 MHz?

Original comment by arduino....@gmail.com on 18 Oct 2011 at 9:33

GoogleCodeExporter commented 8 years ago
No it has not been tuned, how can I do that? And, is it necessary?
Isn't the processor set to run at 8 MHz by flashing from the Arduino IDE? (This 
is what I used)
Looking at boards.txt I see that the low fuse bit is set at 0xE2, which 
represents "no clock division" aka 8mhz. Correct?

Original comment by m.da...@gmail.com on 18 Oct 2011 at 9:47

GoogleCodeExporter commented 8 years ago

It is possible to tune the processor "by hand".  Basically, you have the target 
toggle an output at an expected frequency (say, once per second).  Have 
something else measure the output frequency (say, an Uno).  Adjust OSCCAL (on 
the target processor) until the measured frequency and actual frequency are 
within 1%.

Or, you can use "Tiny Tuner"...
http://arduino.cc/forum/index.php/topic,8553.0.html

> Isn't the processor set to run at 8 MHz by flashing from the Arduino IDE?

No.  The fuse settings have to be changed which is separate from "flashing".  
You can change the fuse settings by selecting the appropriate board and then 
executing Tools / Burn Bootloader.

Original comment by arduino....@gmail.com on 18 Oct 2011 at 10:02

GoogleCodeExporter commented 8 years ago
I feel rather stupid, setting fuses with avrdude separately solved the issue!
Thanks for the quick response! I'll look into tuning.. 

Original comment by m.da...@gmail.com on 18 Oct 2011 at 10:26

GoogleCodeExporter commented 8 years ago

Original comment by arduino....@gmail.com on 18 Oct 2011 at 11:26

GoogleCodeExporter commented 8 years ago

You are welcome.  I am glad you have it working.

Original comment by arduino....@gmail.com on 19 Oct 2011 at 1:51

GoogleCodeExporter commented 8 years ago
Hi! I have a similar problem with an ATTINY85, I tried to set the fuses 
manually with success, but I still receive only 0xFF from serial (for example 
Serial.println("hola mundo") outputs like 7 bytes with 0xFF)

Any hint? I am using the internal clock

Also there is a way to use pin 0 as TX? I need 3 analog inputs and 1 TX in this 
tiny for a small toy. Thanks!

Original comment by erwinr...@gmail.com on 23 Dec 2011 at 4:46

GoogleCodeExporter commented 8 years ago

Have you tuned the processor?  What is connected to the other end?

You can change the TX pin by modifying TinyDebugSerial.h.  The section of 
interest starts at line 610 
(http://code.google.com/p/arduino-tiny/source/browse/trunk/hardware/tiny/cores/t
iny/TinyDebugSerial.h#610).  Change TINY_DEBUG_SERIAL_BIT from 2 to 0.

Original comment by arduino....@gmail.com on 23 Dec 2011 at 6:32

GoogleCodeExporter commented 8 years ago
Tuned = no, will try that thanks!

but I tried making the tx by hand with microdelays testing large ranges of 
delays without success. In the other end there is an arduino just for debug but 
I want to use a sparkfun openlog in the future

Original comment by erwinr...@gmail.com on 23 Dec 2011 at 3:41

GoogleCodeExporter commented 8 years ago
Yey! thanks a lot!! both worked flawessly! Calibration and port change!

Original comment by erwinr...@gmail.com on 23 Dec 2011 at 7:58

GoogleCodeExporter commented 8 years ago
Excellent.  I'm glad you have it working.

Original comment by arduino....@gmail.com on 23 Dec 2011 at 8:09

GoogleCodeExporter commented 8 years ago
Hi All,

It seems that something funny happens around my tiny85 also.
In case I use the 8mhz board type, I cannot get serial working. With 1mhz 
everything is fine.

It seems that something is wrong with the fuse bits:

In case I use attiny85at1, timing is ok. (delay(100) ~ 100ms)
attiny85at8 delay is 8 times slower (delay(100) ~ 800ms), after turning off 
CLK8DIV delay seems to work again. (Fuse L=E2 H=D7) 

Can you confirm that the fuse bits are correct and CPU should run at 8mhz using 
these values?

cheers,

T

Original comment by cserveny...@gmail.com on 3 Jan 2014 at 10:18

GoogleCodeExporter commented 8 years ago
The fuse bits are correct.  You failed to apply them.  Use Tools / Burn 
Bootloader after selecting the 8 MHz board.

Original comment by arduino....@gmail.com on 3 Jan 2014 at 10:59

GoogleCodeExporter commented 8 years ago
Thank you for the quick answer, just realised, that ino tool does not
update them. Thank you anyhow.

Just for the record:
It is not enough to select the model and say upload, you need to burn the
bootloader (even if it is empty for arduino-tinys) because during this
operation arduino ide will update the fuses... Upload won't change the
fuses.

Original comment by cserveny...@gmail.com on 3 Jan 2014 at 11:32