Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. /* setup timer2 with 2usec period */
  2. T2CONbits.T32 = 0;      // timer2: disable 32-bit timer mode
  3. T2CONbits.TCKPS = 0;        // timer2: prescale 1:1
  4. T2CONbits.TCS = 0;      // timer2: asynch
  5. T2CONbits.TGATE = 0;        // timer2: non-gated
  6. PR2 = 40;           // timer2: 40MHz / 40 = 1MHz toggle freq (500kHz signal)
  7. T2CONbits.TON = 1;      // timer2: turn on