Closed svenwiltink closed 4 years ago
Hi @svenwiltink ! Thanks for the PR. The only question is f_cpu
, you specified 800000L
which means 800 kHz, is that true?
I was mistaken:
6.2.1Default Clock SourceThe device is shipped with CKSEL = “0100”, SUT = “10”, and CKDIV8 programmed. The defaultclock source setting is the Internal RC Oscillator with longest start-up time and an initial systemclock prescaling of 8, resulting in 1.0 MHz system clock. This default setting ensures that allusers can make their desired clock source setting using an In-System or Parallel programmer.For low-voltage devices it should be noted that unprogramming the CKDIV8 fuse may result inoverclocking. At low voltages (below 2.7V) the devices are rated for maximum 4 MHz operation(see Section 22.3 on page 200), but routing the clock signal from the internal oscillator directly tothe system clock line will run the device at 8 MHz.
By default the chip is shipped at 1Mhz, but can be clocked all the way to 8Mhz using the interal clock. When using an external clock source it can run at 20Mhz.
After setting the fuses to the correct value it runs at 8Mhz correctly
It looks like 8 MHz is the default choice for this board https://github.com/SpenceKonde/ATTinyCore/blob/master/avr/boards.txt#L2197
With the lfuse set to 0xE4 that is the case. It ships with the divide by 8 flag on though, which results in a 1Mhz clock. I am not sure what the sensible value would be for platform.io. You can change the fuses by editing the platform.io settings, but it doesn't do that by default
I can change it to either 8Mhz or 1Mhz, whichever makes more sense from the pio
perspective
We tend to use the same settings as in the boards.txt
for this board. Please change it to 8MHz as it was before.
Updated
Thanks, merged.
Use tiny instead of tinycore and fixed the f_cpu flag
When using
tinymodern
we get the following error:All the compile errors go away when using the
tiny
core.The f_cpu flag also appears to be wrong. The attiny4313 has an internal oscillator that runs at +-8Mhz. When using an exteral clock it can run up to 20Mhz. See the datascheet: https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-2586-AVR-8-bit-Microcontroller-ATtiny25-ATtiny45-ATtiny85_Datasheet.pdf