I am trying to get two units to synchronize this requires TIMER0 to be re-set to zero on one of the units when the other has a timer0 overflow.
This does not seem to be happening I set TMR0H=b'00000000' then TMR0L=b'00000000' and it doesn't work.
the ASM shows CLRF TMR0H and CLRF TMR0L.
Now according to the datasheet there is something strange about these registers the gist being that you are not actually writing to the registers but to a buffer (which is supposed to update the registers after a TMR0L write).
Any help would be appreciated.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for the help. I started to think it was a prescaler problem, but apparently this should be reset on a TMR0L write. I'm sure I must be doing something daft as I've got this to work on other projects (writing to the registers that is not resetting them). I've never tried to synchronize two timers (and over a RF link).
I will think about it some more and maybe try TIMER1 instead, but this does have a poorer selection of scaling (8:1 is the best it can manage).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Are you sure I'm doing it in the wrong order? I write to TMR0H (to the buffer) then a write to TMR0L will load TMR0L and transfer the value from the TMR0H buffer to the actual register.
Well that's how I interpreted the datasheet.
I have now put the
TMR0H=b'00000100'
TMR0L=b'00000000'
in a different place in the program and it now works (note: I have had to make TMR0H=4 as it is further down in the program and would otherwise miss the transmission on the next wake-up).
All I can think of is that the SPI was (probably) still active when the first attempt at zeroing was made, but would this make a difference?
I am using a RFM69 for the RF link it is sending weather data every 1 minute and I wanted to get receiver and transmitter synchronized to minimize battery use - the outside unit uses 0.9 uA when in sleep. I can post the relevant register values to use for this device if anybody is interested.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
As updating the timer0 registers in order is critical. As you are writing directly to the registers and not using the libraries I would be totally guessing.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am trying to get two units to synchronize this requires TIMER0 to be re-set to zero on one of the units when the other has a timer0 overflow.
This does not seem to be happening I set TMR0H=b'00000000' then TMR0L=b'00000000' and it doesn't work.
the ASM shows CLRF TMR0H and CLRF TMR0L.
Now according to the datasheet there is something strange about these registers the gist being that you are not actually writing to the registers but to a buffer (which is supposed to update the registers after a TMR0L write).
Any help would be appreciated.
Works here. Maybe id works because I force the SetTimer to select the overloaded WORD method.
Evan
Thanks for the help. I started to think it was a prescaler problem, but apparently this should be reset on a TMR0L write. I'm sure I must be doing something daft as I've got this to work on other projects (writing to the registers that is not resetting them). I've never tried to synchronize two timers (and over a RF link).
I will think about it some more and maybe try TIMER1 instead, but this does have a poorer selection of scaling (8:1 is the best it can manage).
Using the inbuilt functions will resolve. You are loading the two registers in the wrong order.
Are you sure I'm doing it in the wrong order? I write to TMR0H (to the buffer) then a write to TMR0L will load TMR0L and transfer the value from the TMR0H buffer to the actual register.
Well that's how I interpreted the datasheet.
I have now put the
TMR0H=b'00000100'
TMR0L=b'00000000'
in a different place in the program and it now works (note: I have had to make TMR0H=4 as it is further down in the program and would otherwise miss the transmission on the next wake-up).
All I can think of is that the SPI was (probably) still active when the first attempt at zeroing was made, but would this make a difference?
I am using a RFM69 for the RF link it is sending weather data every 1 minute and I wanted to get receiver and transmitter synchronized to minimize battery use - the outside unit uses 0.9 uA when in sleep. I can post the relevant register values to use for this device if anybody is interested.
Dunno.
As updating the timer0 registers in order is critical. As you are writing directly to the registers and not using the libraries I would be totally guessing.