January 13, 2018 Written by

The second tutorial was about the power consumption of a device at different operations.

We worked with the operations nop and mul. Nop is a no operation command and mul is the command for multiplication. Due to the fact that the two commands need different times to be computed, we can see with the help of the power consumption, which operation was done.

The first script which was programmed consists of 10 nops followed by 10 muls. The second script consists of 20 nops followed by 10 muls and the third script consists of 10 nops followed by 10 muls followed by 10 nops. The traces were reduced to 500 to consider a smaller area and to recognize the differences between the power consumptions.

First script which was executed:

/**********************************

* Start user-specific code here. */
trigger_high();

//16 hex bytes held in 'pt' were sent
//from the computer. Store your response
//back into 'pt', which will send 16 bytes
//back to computer. Can ignore of course if
//not needed

asm volatile(
"nop"       "\n\t"
"nop"       "\n\t"
"nop"       "\n\t"
"nop"       "\n\t"
"nop"       "\n\t"
"nop"       "\n\t"
"nop"       "\n\t"
"nop"       "\n\t"
"nop"       "\n\t"
"nop"       "\n\t"
::
);

asm volatile(
"mul r0,r1" "\n\t"
"mul r0,r1" "\n\t"
"mul r0,r1" "\n\t"
"mul r0,r1" "\n\t"
"mul r0,r1" "\n\t"
"mul r0,r1" "\n\t"
"mul r0,r1" "\n\t"
"mul r0,r1" "\n\t"
"mul r0,r1" "\n\t"
"mul r0,r1" "\n\t"
::
);

trigger_low();
/* End user-specific code here. *

********************************/

The code consists of 10 nops followed by 10 muls.

The second and third scripts only differ in the code-blocks that were used.

Plots of the different traces that were made:

Illustration 1: 10 nops 10 muls, 20 nops 10 muls and 20 nops 10 muls 10 nops

As you can see in illustration 1 the first area of the plot lengthen when we use more operations. This means, that the chip needs more time for computing as expected. The nop needs not as much power as the mul as you can see in the three illustrations in the area from 0 to 200 samples.

You can see in illustration 1 that the dotted line shows the point where execution of the nops stopped and the execution of the muls began. By comparing the lines with the lines in the other two illustrations, we were able to compute the time the chip needs to do one of the operations. Now you only have to divide the amount of samples by the amount of the muls and you will get around 8 samples per mul. At an ADC-Clock of 29.5MHz the execution of a mul will last about 0.271µs and the execution of a nop will last about 0.1356µs.

After the three tests of the different power consumptions we changed a setting which affect to the Clock-Phase. With a changed Clock-Phase the waveform of the plots also changes. The plots which were made witch the changed Clock-Phase are given below:

Illustration 2: 0°-Phase Adjust, 50°-Phase Adjust and 150°-Phase Adjust

If you compare the illustration 2 you will recognize that the plots doesn´t differ that much from each other. But on the second sight you will recognize that the marked points at sample 14 are different in all 3 plots. In the top chart it´s not an obtuse angle but it is not as acute as the angle in the last chart.

The Phase-Adjustment conduces to recognize distinctive points when you normally won´t recognize them with 0°-Phase-Adjustment. This kind of problem can occur if the speed of computing is much higher than the frequency of sampling.