Go Down

Topic: Arduino interval per sample read (Read 731 times) previous topic - next topic

GolamMostafa

Code: [Select]
The first problem is that not all instructions take 1 clock cycle. The datasheet's instruction set reference will tell you exactly how long each statement will take. A small detail.

The second problem is the statements themselves. You see that [b]brcc[/b] line? That means [url=http://www.atmel.com/webdoc/avrassembler/avrassembler.wb_BRCC.html]Branch if Carry Cleared[/url]. It is a conditional instruction, so evaluating how long the function takes is not just a matter of summing up all the lines. It branches to a line above it (to [b]LC:[/b]), so that also means it is a [i]loop[/i]. How long the function takes will depend on how many times that [b]brcc[/b] statement branches back to the LC: label.

How many times does it branch? That's the interesting question, isn't it.
[/quote]

1. Data sheets (P433) says: brcc takes 1/2 cycles. As I have learnt - the control will take 1 cycle time to
    move to the direction where the condition is satisfied; the other direction will take 2 cycles.

2. The brcc LC is certainly a loop. How many times will it branch? I never thought about it - thinking now!
    In fact, what we see in the from of ASM (C) instructions, they are the timing functions of the 'State
    Machines' within the microcontroller/microprocessor engaged in the propagation of information across
    high speed gates and flip-flops. So, number of branching could be approximated to a one-dimensional
    negligible time like sin& ----> &.

3. Anyway, thanks for bringing forward a thought provoking issue which we find very rarely in a Public
    Forum - a conglomerate of Merchants.
   

Smajdalf

So, number of branching could be approximated to a one-dimensional
    negligible time like sin& ----> &.
What? If you want (or are not careful) you can stay in a loop forever. Eternity is negligible for you?
On 8-bit (i.e. Uno) use "byte" instead of "int" if possible - it is faster and saves resources!

GolamMostafa

What? If you want (or are not careful) you can stay in a loop forever. Eternity is negligible for you?
You are right; but, I have assumed that the conversion will come to an end shortly and the loop will be stopped.

Smajdalf

No. Waiting for conversion to finish takes most of the time if main clock is 16 MHz and you want to stay in specs to maintain 10 bit resolution.
On 8-bit (i.e. Uno) use "byte" instead of "int" if possible - it is faster and saves resources!

Go Up