SpenceKonde / megaTinyCore

Arduino core for the tinyAVR 0/1/2-series - Ones's digit 2,4,5,7 (pincount, 8,14,20,24), tens digit 0, 1, or 2 (featureset), preceded by flash in kb. Library maintainers: porting help available!
Other
551 stars 142 forks source link

Improve performance and flash usage of basic core libraries #163

Closed SpenceKonde closed 4 years ago

SpenceKonde commented 4 years ago

They currently use PROGMEM and the pgm_read_byte() call - because of the unified memory architecture of the tinyAVR 0-series and 1-series parts, this can be changed without loss of functionality to simply use const[] variables and cut out the extra LPM instruction.

SpenceKonde commented 4 years ago

This is now implemented. The performance implications of this were bizarre - it SLOWED pinmode by 6 clocks (no idea why - I mean I can see why from the assembly listing: it's pushing r28 and r29 onto the stack at the start of pinMode, and popping them at the end - (2+1)*2=6 - but why it has to do this isn't clear, since it doesn't seem to actually use those registers....), sped up digitalWrite by 2 clocks.... and digitalRead() by an insane 52 clocks (almost 2:1!) and analogWrite() by 25. Since it's on balance an improvement, it's going into the release.