summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--openpcd/firmware/src/tc.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/openpcd/firmware/src/tc.c b/openpcd/firmware/src/tc.c
index 5318644..4a0189b 100644
--- a/openpcd/firmware/src/tc.c
+++ b/openpcd/firmware/src/tc.c
@@ -19,14 +19,20 @@ void tc_cdiv_set_divider(u_int16_t div)
tcb->TCB_TC0.TC_RC = div;
/* set to 50% duty cycle */
- tcb->TCB_TC0.TC_RA = 0;
- tcb->TCB_TC0.TC_RB = div >> 1;
+ tcb->TCB_TC0.TC_RA = 1;
+ tcb->TCB_TC0.TC_RB = 1 + (div >> 1);
}
void tc_cdiv_phase_add(int16_t inc)
{
tcb->TCB_TC0.TC_RA = (tcb->TCB_TC0.TC_RA + inc) % tcb->TCB_TC0.TC_RC;
tcb->TCB_TC0.TC_RB = (tcb->TCB_TC0.TC_RB + inc) % tcb->TCB_TC0.TC_RC;
+
+ /* FIXME: can this be done more elegantly? */
+ if (tcb->TCB_TC0.TC_RA == 0) {
+ tcb->TCB_TC0.TC_RA += 1;
+ tcb->TCB_TC0.TC_RB += 1;
+ }
}
void tc_cdiv_init(void)
personal git repositories of Harald Welte. Your mileage may vary