From c8ab4f8865a7f2b15f1edf398640dc85caaed843 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@6dc7ffe9-61d6-0310-9af1-9938baff3ed1> Date: Tue, 8 Aug 2006 22:23:55 +0000 Subject: prevent CARRIER_DIV_HELP from becoming permanently zero git-svn-id: https://svn.openpcd.org:2342/trunk@90 6dc7ffe9-61d6-0310-9af1-9938baff3ed1 --- openpcd/firmware/src/tc.c | 10 ++++++++-- 1 file 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) -- cgit v1.2.3