-1

Please explain the set timer function in this code. Also what it does and what is the number 60535 used with set timer function.

case 0: if (int_innercount == 0)
        {
           output_low(PIN_B5);
           output_low(PIN_B6);
           output_low(PIN_B1);
           int_innercount = 1+int_innercount;
           set_timer1(60535);
        }
        else if (int_innercount == 1)
        {
           output_high(PIN_B1);
           int_innercount = 1+int_innercount;
           set_timer1(65035);
        }
        else
        {
           output_low(PIN_B1);
           int_count = 1+int_count;
           int_innercount = 0;
           set_timer1(65035);
        }
     break;
Paul R
  • 208,748
  • 37
  • 389
  • 560
  • 1
    65035 = 65535 - 500, so I would guess that it's an up-counter which triggers an interrupt or sets a flag when it overflows. The code is therefore probably just initialising a count of 500 in the timer register. – Paul R Apr 19 '16 at 07:07
  • 2
    User manual................ – Martin James Apr 19 '16 at 08:04

1 Answers1

0

It loads a 16 bit unsigned value into the timer1 register. Because that PIC is a 8-bit machine, loading the 16 bit timer would normally take 2 8 bit assignments. The function is provided for convenience.

The manual says nothing about atomicity. So it's best to assume the assignment is non-atomic.

Unimportant
  • 2,076
  • 14
  • 19