gillham / logic_analyzer

Implementation of a SUMP compatible logic analyzer for the Arduino
Other
463 stars 99 forks source link

Unrolled code for 2 and 4 MHz is flawed #14

Closed stowite closed 11 years ago

stowite commented 11 years ago

The conditional compilation logic in the code for the 2 MHz (logic_analyzer_inline_2mhz.ino) and the 4 MHz (logic_analyzer_inline_4mhz.ino) is flawed. For example in the 2 MHz code one sees ...
logicdata[530] = CHANPIN;
INLINE_NOP;
logicdata[531] = CHANPIN;
INLINE_NOP;

if defined(AVR_ATmega328P)

logicdata[532] = CHANPIN;
INLINE_NOP;

...

logicdata[1022] = CHANPIN;
INLINE_NOP;
logicdata[1023] = CHANPIN;
INLINE_NOP;

elif defined(AVR_ATmega1280) || defined(AVR_ATmega2560)

logicdata[1024] = CHANPIN;
INLINE_NOP;
logicdata[1025] = CHANPIN;
INLINE_NOP;

...

which means that only the ATmega328P ever uses locations 532 to 1023 inclusive.

For anything else this results in a gap in the record sent to the client since the 'logicdata' locations in this range are never used.

jancumps commented 11 years ago

The issue is analyzed at JavaRanch & youtube: http://www.coderanch.com/t/619382/arduino/Testing-Arduino-logic-analyzer http://youtu.be/JDUkaX3wfXg

gillham commented 11 years ago

Thanks for submitting this issue. I fixed the preprocessor logic. It should have been checking all three types on the first one and no 'elif' on the second. It looks good on my Mega now. Let me know if you see any more issues in v0.12.

jancumps commented 11 years ago

Thank you!