Go Down

Topic: ATMEL ATTINY85 - How to switch clock to 128 kHz or less? (Read 763 times) previous topic - next topic

mpcz

Hello,
upload to TINY85:

avrdude -B250 -c usbasp -p t85 -U lfuse:w:0x04:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m ....

The base frequency is reduced. 8x division does not work.
Where is the error?
Thanks, mpcz, 16.oct.2017

Smajdalf

Maybe you chande main clock prescaler in your code?
On 8-bit (i.e. Uno) use "byte" instead of "int" if possible - it is faster and saves resources!

mpcz

Yes, the change in code "clock/8" works OK.
I need a change of "frequency and divider" via FUSE.
mpcz, 16.oct.2017

Smajdalf

The fuse sets prescaler to divide by 8. If you change it via code later the value from fuse is overwritten. I.e. if it is set by fuse to 8 and you set it to 8 too you get total prescaling 8 (~16kHz), not 64 (~2kHz). Isn't this your problem?
On 8-bit (i.e. Uno) use "byte" instead of "int" if possible - it is faster and saves resources!

mpcz

Sorry, I do not understand.
I set fuses:
avrdude -B250 -c usbasp -p t85 -U lfuse:w:0x04:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m
The code is empty. Frequency is 128k, not 16kHz.
What is wrong?
Thank, mpcz, 16.oct.2017

Smajdalf

Are you sure the code is empty? Are you sure no core/bootloader is present that sests the prescaler to 1? Try to add
-e
command line option to the avrdude command to erase possible remnants from the chip.
On 8-bit (i.e. Uno) use "byte" instead of "int" if possible - it is faster and saves resources!

DrAzzy

ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

mpcz

I have an ocsiloscope attached to pin # 3, there is an output clock.
mpcz, 16.oct.2017

Smajdalf

How do you know the code is empty? Did you erase the chip? Try to read flash to be sure it is empty.
On 8-bit (i.e. Uno) use "byte" instead of "int" if possible - it is faster and saves resources!

DrAzzy

Sanity check...

Upload blink to it via ICSP, compiled for 128khz. Does it blink for 1 second or for 8 seconds?

I agree with your assessment though, it should be outputting - and running at - 16khz!

I would also consider trying to set the prescaler from the application (or at least read it out and blink an LED that many times, or something...)
ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

Go Up