Go Down

Topic: Attiny85 serial comms (Read 10720 times) previous topic - next topic

brainbooster

is there any way to let the attiny85 (uart-less) communicate with a softwareserial when it's clocked at 1mhz?
i would like to connect it to a serial lcd.
i've compiled against the 45_85 core and the arduino tiny core but without success.
any help ?

spycatcher2k

You could set the internal osc. to 8Mhz:

lfuse:w:0xE2:m
hfuse:w:0xD9:m
efuse:w:0xFF:m

By default its got CKDIV8 set, so devides clock by 8.
Then retry your sketch - i've never tried that library myself on these chips.
If it works, post back plz.


Drew.
-=-
http://www.uk-pcb.co.uk - UK Based PCB Fab & Assembly Company
Design & Assembly work undertaken - Arduino repairs & testing - PM for details. Arduino & C# PC programming.

brainbooster

#2
Apr 17, 2011, 04:45 pm Last Edit: Apr 17, 2011, 04:58 pm by BrainBooster Reason: 1
thank you for your reply
tested and it doesn't work too.. :(
i know , the core i'm using has a tinydebugserial, but i cant find examples around...
i would also be happy with a tx only solution
Edit:
my fuses are:
lfuse E2
hfuse DF
efuse FF
and avrdude says they're ok

spycatcher2k

-=-
http://www.uk-pcb.co.uk - UK Based PCB Fab & Assembly Company
Design & Assembly work undertaken - Arduino repairs & testing - PM for details. Arduino & C# PC programming.

brainbooster

i saw it , but it says 4800bps, i need 9600 because the serial lcd only works at that baudrate..
do you think it could be modified to reach 9600bps?

spycatcher2k

#5
Apr 17, 2011, 05:14 pm Last Edit: Apr 17, 2011, 05:20 pm by spycatcher2k Reason: 1
Possibly, but a 16 Mhz crystal would be needed for  your chip, or the line

 _bitPeriod = 1000000 / _baudRate;

COULD be the key, maybe clock the chip @ 8Mhz & change it to :

 _bitPeriod = 8000000 / _baudRate;


Not at home so can't test myself.


Drew.


ARghh  . . . . Missread source , the above is a load of b*ll*cks.
-=-
http://www.uk-pcb.co.uk - UK Based PCB Fab & Assembly Company
Design & Assembly work undertaken - Arduino repairs & testing - PM for details. Arduino & C# PC programming.

spycatcher2k

#6
Apr 17, 2011, 05:17 pm Last Edit: Apr 17, 2011, 05:44 pm by spycatcher2k Reason: 1
also saw this

SoftwareSerial appears to have some timing issues and/or software issues. Check this forum thread for discussion. Software Serial Discussion. In particular, if you are having problems using SoftwareSerial with an Atmega168 chip delete SoftwareSerial.o in your Arduino directory.


or try this update http://arduiniana.org/NewSoftSerial/NewSoftSerial10c.zip

[This version of NewSoftSerial supports only 20, 16 and 8MHz processors

Drew.
-=-
http://www.uk-pcb.co.uk - UK Based PCB Fab & Assembly Company
Design & Assembly work undertaken - Arduino repairs & testing - PM for details. Arduino & C# PC programming.

brainbooster

#7
Apr 17, 2011, 06:14 pm Last Edit: Apr 17, 2011, 07:45 pm by BrainBooster Reason: 1
thank you for your advice, but i know newsoftwareserial leans on interrupts and it wont work out of the box with the attiny85.
i would avoid to use interrupts if it is possible..
Edit:
anyway , programming fuses at 8mhz let the newsoftwareserial (with some modifications) actually work, but i'm afraid about interrupts and timers screwing up, but  now at least i can read my hallo world on my lcd.

Coding Badly

Quote
is there any way to let the attiny85 (uart-less) communicate with a softwareserial when it's clocked at 1mhz?


It depends.  Do you need to be able to receive, transmit, or both?

westfw

For transmit-only to a serial LCD, you should certainly be able to do 9600bps even on a 1MHz AVR.  That's about 106 microseconds per bit (or instructions, at 1MHz, approximately); plenty of time!
However, the arduino "softwareserial" library is not a particularly good place to start for doing this, since it's designed to use interrupts to allow several concurrent receive/transmit serial ports, which is overkill, and the timer-based interrupts may not work correctly on a tiny85, either.

brainbooster

that's the what i thought for first... it should be not so complicate to bitbang an rs232 frame.. divide the clock and the baudrate to have the delay between two subsequent bits, send the start bit, transform the char in byte and send the 0 or the 1, send the stop bit.
But with this method in my tests, if i send   "aaaa" i receive sometimes "aaaq" or sometimes the right string, or randomly "qqaq", i guess because of the internal oscillator and his low precision.
do you think TinyTune may help?
and why when i use the arduinoTiny core i'm not able to do it via the tinydebug serial at 1mhz?

Coding Badly

Quote
that's the what i thought for first... it should be not so complicate to bitbang an rs232 frame.. divide the clock and the baudrate to have the delay between two subsequent bits, send the start bit, transform the char in byte and send the 0 or the 1, send the stop bit.


That's exactly how Tiny Debug Serial works.

But with this method in my tests, if i send   "aaaa" i receive sometimes "aaaq" or sometimes the right string, or randomly "qqaq", i guess because of the internal oscillator and his low precision.


The untuned internal oscillator is probably why serial communications does not work.

Quote
do you think TinyTune may help?


It has helped me.  If the temperature and voltage is fairly stable I've been able to tune the internal oscillator to ±0.5%.  Which is certainly good enough for serial communications to work.

Quote
and why when i use the arduinoTiny core i'm not able to do it via the tinydebug serial at 1mhz?


It worked when I tested it.   :D  Try tuning the processor.

Go Up