0 favorites     0 comments    98 visits

See also...


Keywords

electronics
stupidity
AVR
logic analyzer
code optimization


Authorizations, license

Visible by: Everyone
All rights reserved

98 visits


1st optimization attempt

1st optimization attempt
When dealing with this I realized (finally) that I could remove duplicate code and use this as the replacement:

uint8_t bit_value = _BV(bit);

if(bit <= 7) { // read data-bits 0...7
if( (PINA & _BV(PA0)) ) {
soft_uart_rx_byte |= bit_value;
} else {
soft_uart_rx_byte &= ~bit_value;
}
[...]

Now the _BV(bit) expression has to be evaluated just once. But that didn't help at all. It seems the compiler had already optimized the previous code.

Comments

Sign-in to write a comment.