Timeline for Optimizing code for ATtiny10
Current License: CC BY-SA 4.0
21 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Feb 5, 2022 at 21:33 | answer | added | CWallach | timeline score: 1 | |
S Feb 5, 2022 at 8:39 | history | suggested | Peter Mortensen | CC BY-SA 4.0 |
Copy edited (e.g. ref. <www.microchip.com/en-us/product/ATtiny10>, <en.wikipedia.org/wiki/Light-emitting_diode>, and <en.wikipedia.org/wiki/Printed_circuit_board>). In English, the subjective form of the singular first-person pronoun, "I", is capitalized. "Need help" is implied by posting here.
|
Feb 5, 2022 at 2:57 | comment | added | Peter Mortensen | Aren't the LEDs quite weak? Isn't the default I/O input? The code as presented here would seem to switch the internal pull-up resistors on and off (as none of the I/O pins are set up as output). Switching the internal pull-up resistors on and off will produce some light on the LEDs, but not very much. The current through them will only be on the order of 0.1 mA (100 µA). Or is there some kind of driver circuit that makes up for it? | |
Feb 5, 2022 at 2:40 | comment | added | Peter Mortensen | Related: Optimizing code to use less flash memory and SRAM and What can I do if I run out of flash memory or SRAM? | |
Feb 5, 2022 at 1:40 | review | Suggested edits | |||
S Feb 5, 2022 at 8:39 | |||||
Feb 4, 2022 at 23:12 | comment | added | copper.hat | How big is the code if you replace random by a constant? | |
Feb 4, 2022 at 14:01 | answer | added | Redy000 | timeline score: 7 | |
Feb 4, 2022 at 3:01 | history | tweeted | twitter.com/StackArduino/status/1489433783652732934 | ||
Feb 3, 2022 at 22:38 | history | became hot network question | |||
Feb 3, 2022 at 15:39 | answer | added | Edgar Bonet | timeline score: 12 | |
Feb 3, 2022 at 15:38 | answer | added | Dave X | timeline score: 3 | |
Feb 3, 2022 at 15:38 | comment | added | Dave X |
Are your pins and pinMode()s correct? pinMode(3,INPUT) seems like the default, and the random HIGHs on 0&1 seem inconsistent with the LOWS on 1&2
|
|
Feb 3, 2022 at 15:17 | comment | added | João Alves | Please take a look at an article I wrote some time ago regarding AVR code optimizations. | |
Feb 3, 2022 at 15:16 | comment | added | Majenko | @EdgarBonet On such a small device I'd get rid of avr-libc and program it in assembly... | |
Feb 3, 2022 at 15:14 | comment | added | Edgar Bonet | On such a small device, I would get rid of the Arduino core and program at the avr-libc level. | |
Feb 3, 2022 at 14:58 | comment | added | Majenko |
also also random() is a wrapper around rand() which probably wastes bytes. Use rand() & 1 to get a random 1 or 0.
|
|
Feb 3, 2022 at 14:57 | comment | added | Majenko |
digitalWrite(ranNum & 1, HIGH) -- also use a uint8_t instead of an int .
|
|
Feb 3, 2022 at 14:55 | comment | added | Earthbound Ruben | I'm unsure about how direct port forwarding works i'll look up some tutorials thanks for the suggestion. The ternary operator doesnt seem to save any bytes good suggestion tho | |
Feb 3, 2022 at 14:45 | comment | added | Michel Keijzers |
Not sure if it helps byte wise but you can change if(ranNum == 0) { digitalWrite(0, HIGH); } else { digitalWrite(1, HIGH); } into digitalWrite(ranNum == 0 ? 0 : 1, HIGH);
|
|
Feb 3, 2022 at 14:42 | comment | added | chrisl |
I'm not sure what the compiler would optimize out in this situation, but have you tried using direct port manipulation instead of using digitalWrite() , digitalRead() and pinMode() . When not using this the compiler might optimize these functions out.
|
|
Feb 3, 2022 at 14:38 | history | asked | Earthbound Ruben | CC BY-SA 4.0 |