tune timing

This commit is contained in:
King Kévin 2014-07-19 12:57:10 -07:00
parent 280211a76d
commit 84e3c79435
1 changed files with 4 additions and 7 deletions

View File

@ -58,20 +58,17 @@ uint16_t __at(_CONFIG) __CONFIG = _CPD_OFF & // no data code protect
// 0x2100 comes from the PIC12F629 Memory Programming document
__code uint8_t __at(0x2100) EEPROM[] = {0xc9, 0x17, 0xc2, 0x00};
/* set timer in ms */
#define TICKS_PER_MS 145UL // the number of timer 1 ticks to wait for 1ms, using the internal 4MHz clock and a prescaler of 8, and hand tuning
void timer_1ms() {
TMR1ON = 0; // disable timer 1 (to write value safely)
TMR1L = (0xffff-1*TICKS_PER_MS); // set time
TMR1H = (0xffff-1*TICKS_PER_MS)>>8; // set time
TMR1L = 0x6e; // set time (tuned per hand)
TMR1H = 0xff; // set time
TMR1ON = 1; // start timer 1
}
void timer_2ms() {
TMR1ON = 0; // disable timer 1 (to write value safely)
TMR1L = (0xffff-2*TICKS_PER_MS); // set time
TMR1H = (0xffff-2*TICKS_PER_MS)>>8; // set time
TMR1L = 0x22; // set time (tunef per hand)
TMR1H = 0xff; // set time
TMR1ON = 1; // start timer 1
}