"Fast digital pin must be a constant' question constant in class #445
Replies: 1 comment
-
The optimizer is not smart enough to perform much of any optimization the moment classes come into play. That's why libraries that involve classes tend to use so much flash, as I understand it. digitalWriteFast needs the pin to really be known (no allowance for another instance of a class with a different constant pin - that'd have to have it's own copy of that method: the instruction digitalWriteFast compiles to is a cbi/sbi instruction, and the opcode contains the number of the register to operate on within the low IO space (0-31) and the bit (0-7).... I am not very good with C++ classes so I can't offer much more on whether there's a way to make the optimizer do it.... But that's why it's that way. If you want to flip a pin in a single clock cycle, that's what it takes :-P |
Beta Was this translation helpful? Give feedback.
-
why not work ? tr_pin constant.
need compile config to -O3 ?
Beta Was this translation helpful? Give feedback.
All reactions