Hi Everyone-
I'm having a very strange problem with my timers and I suspect its
just a bit-twiddling setup issue. I've implemented the MODBUS RTU
serial protocol which terminates a message when an idle time 3.5
character times is detected. So, I initialize my match register at
0x5573 (3.5 character times at my clock speed) and interrupt upon
match. While receiving characters, I simply try and reset the timer
to prevent it expiring if the character came in within the 3.5
character time. If the character comes in after the 3.5 character
time, an interrupt is triggered and the message is terminated. I am
finding, however, that immediately after starting the timer the TC
register is equal to the match register and the interrupt is
generated.
I call teh following code every time I receive a character:
// Disable the counter clock.
//m_regPtr->regTCR = REG_TMR_TCR_INIT;
// Disable the match interrupt.
m_regPtr->regMCR &= ~REG_TMR_MCR_INT_MR0_MASK;
// Stop the timer.
m_regPtr->regTCR &= ~REG_TMR_TCR_ENABLE_MASK;
// Clear any pending interrupts.
m_regPtr->regIR = REG_TMR_IR_INIT;
// Reset the timer.
m_regPtr->regTCR |= REG_TMR_TCR_RESET_MASK;
m_regPtr->regTCR &= ~REG_TMR_TCR_RESET_MASK;
// Enable the match interrupt.
m_regPtr->regMCR |= REG_TMR_MCR_INT_MR0_MASK;
// Start the timer.
m_regPtr->regTCR |= REG_TMR_TCR_ENABLE_MASK;
-TimMessage
LPC2138 Timer
2006-02-06 by tah2k
Attachments
- No local attachments were found for this message.