RTCC & prescaler manipulation
Kypec
Posts: 5
Please give me anybody a straight answer to this:
Is prescaler also cleared (initialized to zero) when RTCC register
is modified (cleared or written to)?
In the datasheets I found only a statement that prescaler gets
cleared when assigned to WDT and clr !WDT opcode is executed.
According to my observations during simulation in SXSim 2.04
the prescaler is not cleared when clr RTCC is executed.
This behaviour is quite annoying to me. I'm an experienced PICmicro
developer and find it rather difficult to use RTCC for proper timing.
Consider the conditions below:
machine cycle time = 50 ns (20 MHz crystal, TURBO)
prescaler assigned to RTCC = 1:64
My routine is attempting to measure time elapsed
between two consecutive edge occurrences at pin RB0.
Wake-up pending bits testing is involved without interrupt servicing.
After the first edge is detected I zero the RTCC and wait for another edge.
However, since the prescaler is not cleared at that very moment as well,
my reading of RTCC can be misaligned by as much as 63 machine cycles
Anyway, I seem to have to live with that cause no software
can change the behaviour of silicon
Is prescaler also cleared (initialized to zero) when RTCC register
is modified (cleared or written to)?
In the datasheets I found only a statement that prescaler gets
cleared when assigned to WDT and clr !WDT opcode is executed.
According to my observations during simulation in SXSim 2.04
the prescaler is not cleared when clr RTCC is executed.
This behaviour is quite annoying to me. I'm an experienced PICmicro
developer and find it rather difficult to use RTCC for proper timing.
Consider the conditions below:
machine cycle time = 50 ns (20 MHz crystal, TURBO)
prescaler assigned to RTCC = 1:64
My routine is attempting to measure time elapsed
between two consecutive edge occurrences at pin RB0.
Wake-up pending bits testing is involved without interrupt servicing.
After the first edge is detected I zero the RTCC and wait for another edge.
However, since the prescaler is not cleared at that very moment as well,
my reading of RTCC can be misaligned by as much as 63 machine cycles
Anyway, I seem to have to live with that cause no software
can change the behaviour of silicon
Comments
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out· the "SX-Video Display Module"
www.TerryHittConsulting.com
·
Post Edited (Paul Baker) : 2/19/2005 5:34:28 PM GMT
please don't take the results achieved with SXSim for granted - especially such prescaler-related issues might not yet reflect the "real silicon".
Nevertheless, I'm glad that you came up with this question. I'll check how a "real" SX handles it, and then will adjust SXSim if necessary.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
Quotation from the Unit 7: Interrupts
Anyway, I'm eagerly waiting for new SXSim release
Kypec
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out· the "SX-Video Display Module"
www.sxvm.com
·