SpenceKonde / arduino-tiny-841

Arduino core for ATtny841, 828, 1634 and 441
http://drazzy.com/e/tiny841.shtml
Other
28 stars 8 forks source link

SoftwareSerial library is an older, shittier version than it should be #6

Closed SpenceKonde closed 9 years ago

SpenceKonde commented 9 years ago

Per jboynton on pg7: http://forum.arduino.cc/index.php?topic=304606.90

Also needs to be fixed in other ATTiny core.


I tested SoftwareSerial on an ATtiny841. I tried three different baud rates and changed the system oscillator frequency by tuning the internal 8MHz oscillator calibration registers. What I found was that SoftwareSerial seemed to work at these frequencies:

9600:  7.5-8.5 MHz
19.2:     7.9-8.6 MHz
38.4:    7.6-7.7 MHz

This seemed weird since I'd only recently tested an Atmega328 and the results were different. I finally came to realize that SoftwareSerial had undergone a change with 1.6.x IDE. It appears to have been an improvement. The 1.6.x 841 core uses the older 1.0.x SoftwareSerial.

Using the 1.6.x SoftwareSerial I got these values:

9600:  7.6-8.4 MHz
19.2:     7.6-8.3 MHz
38.4:    7.8-8.2 MHz

The frequencies aren't highly precise because the internal oscillator has a lot of jitter. But the ranges where it worked were better centered around 8Mhz with the 1.6.x version. Also, the 1.6.x SoftwareSerial is 306 bytes smaller in code size. It uses only 3 bytes extra RAM.

I copied SoftwareSerial.cpp and .h into my hardware/arduino-tiny-841 folder. But rather than have this duplication, is there any way to set up the core so that the SoftwareSerial library in the 1.6.x core is used instead?
SpenceKonde commented 9 years ago

Updated to software serial from 1.6.3