Ernest Snaith


Discussion created by Ernest Snaith on Dec 16, 2006
Latest reply on Dec 16, 2006 by Mark Hotchkiss
I was wondering why my code cycle repeated itselft so slowly and decided to see what part of it took so long. In the end i got the down to;
void main(void) {  EnableInterrupts;  TSCR1 = 0x80;               //ENABLE TIMER  TSCR2 = 0x04;        //PRESCALER SET TO 16  for(;;)   {    Marker9 = Marker8;    Marker8 = Marker7;    Marker7 = Marker6;    Marker6 = Marker5;    Marker5 = Marker4;    Marker4 = Marker3;    Marker3 = Marker2;    Marker2 = Marker1;    Marker1 = TCNT;                       }}

I then looked at the marker values and was amazed to see that each differed by 3-4 increments of the timer. with a timer prescaler of 16 thats 45-60 bus cycles is it not? Why is such a simple operation taking so long?