diff -c irt-06\sctimer.c irt\sctimer.c *** irt-06\sctimer.c Fri Oct 31 17:51:05 2014 --- irt\sctimer.c Thu Dec 04 11:23:14 2014 *************** *** 12,17 **** --- 12,18 ---- void sct_enable_carrier(void); void sct_disable_carrier(void); + u_long Tdiv; /* =============================================================== */ *************** *** 21,27 **** void sctimer_c_init(u_long sysCLK) { u_long n, tmp; ! u_long Tdiv, Tdiv_half; /* * enable clock for SCT --- 22,28 ---- void sctimer_c_init(u_long sysCLK) { u_long n, tmp; ! u_long Tdiv_half; /* * enable clock for SCT *************** *** 55,60 **** --- 56,63 ---- */ Tdiv = sysCLK / (38 * 1000); Tdiv_half = Tdiv / 2; + Tdiv -= 1; /* set (n-1) for 1/n */ + Tdiv_half -= 1; LPC_SCT->CONFIG = 0 | (1<<0) /* 32bit operation */ *************** *** 151,157 **** */ void sct_enable_carrier(void) { ! LPC_SCT->CTRL_U |= SCT_CTRL_CLRCTR_L; /* clear counter */ LPC_SCT->CTRL_U &= ~SCT_CTRL_HALT_L; /* release halt */ } --- 154,161 ---- */ void sct_enable_carrier(void) { ! // LPC_SCT->CTRL_U |= SCT_CTRL_CLRCTR_L; /* clear counter */ ! LPC_SCT->COUNT_U = Tdiv; /* make first match just after start */ LPC_SCT->CTRL_U &= ~SCT_CTRL_HALT_L; /* release halt */ }