diff options
author | (no author) <(no author)@6dc7ffe9-61d6-0310-9af1-9938baff3ed1> | 2006-08-08 22:23:55 +0000 |
---|---|---|
committer | (no author) <(no author)@6dc7ffe9-61d6-0310-9af1-9938baff3ed1> | 2006-08-08 22:23:55 +0000 |
commit | c8ab4f8865a7f2b15f1edf398640dc85caaed843 (patch) | |
tree | adde6a831610abf44f0c37fb4b85214df8e8cf49 | |
parent | 8e4fab424777ca316042e9b93502484de58217fb (diff) |
prevent CARRIER_DIV_HELP from becoming permanently zero
git-svn-id: https://svn.openpcd.org:2342/trunk@90 6dc7ffe9-61d6-0310-9af1-9938baff3ed1
-rw-r--r-- | openpcd/firmware/src/tc.c | 10 |
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) |