Arduino Uno (ATMega328P Microcontroller) running inline assembly instructions using asm statements. Global interrupts disabled. Pin 13 (PORTB5), DDRB5 designated as output used for trigger event for oscilloscope. The oscilloscope is measuring voltage drop of resistor soldered to VCC on microcontroller and using pin 13 toggle as trigger event. Clock of microcontroller is 16MHZ and the oscilloscope is sampling at 1.25GHZ.


The traces acquired from the setup above are relatively uniform. However, they give some odd behaviour causing some errors in my analysis. Every 8 or 16 clock cycles, the waveform will peak on the trailing edge. Reading documentation of the microcontroller about the fetch-load-execute cycle does not lead to any nice conclusions. Has anyone else encountered this issue?

  • \$\begingroup\$ What specific code is the microcontroller running? \$\endgroup\$ – duskwuff Jul 24 '18 at 22:28
  • \$\begingroup\$ Would you like me to post a picture as well? \$\endgroup\$ – Mir Jul 24 '18 at 22:34
  • \$\begingroup\$ @duskwuff I have posted code snippets. Take a look. \$\endgroup\$ – Mir Jul 24 '18 at 22:53
  • \$\begingroup\$ An artifact from sampling? \$\endgroup\$ – Janka Jul 24 '18 at 23:12
  • \$\begingroup\$ Do you have any examples come to mind? The trace above is averaged from 25,000 traces, so I would assume any artifacts would be smoothed out. The large peaks occur deterministically and continuously through a trace 50,000 data points long as well as other instruction traces. The 'artifact from sampling' repeating with such precision seems too peculiar. \$\endgroup\$ – Mir Jul 24 '18 at 23:17

My suspicion would be that it has nothing to do with the instructions at all. Something else in the microcontroller is becoming active every 8 and/or 16 clock cycles.

A couple of possibilities that come to mind are:

  • A timer/counter peripheral has its clock prescaler set to 8.

  • One of the timer/counter peripherals is rolling over every 8 or 16 clock cycles.

  • The SPI peripheral has its clock prescaler set to 16.

  • The TWI (aka. I2C) peripheral has its clock prescaler set to 16.

  • The CKDIV8 fuse is programmed.

  • \$\begingroup\$ Thank you for giving an answer. I will research these and come back with an update. I also agree with your assumption it has nothing to do with the instructions. Viewing the compiled code hex dump reveals there are no instructions partitioning the block of adds instructions. \$\endgroup\$ – Mir Jul 25 '18 at 12:50
  • \$\begingroup\$ Quick update: I am looking into all the hardware components and attempting to turn off unnecessary peripherals with the Low Power library. Once completed, I will come back with more details. \$\endgroup\$ – Mir Jul 26 '18 at 21:14
  • \$\begingroup\$ Turned off all timer peripherals, TWI, SPI and the data remains consistent. Will check alignment issues above hinted by @Janka. Thank you again for the ideas. \$\endgroup\$ – Mir Jul 30 '18 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.