Shop OBEX P1 Docs P2 Docs Learn Events
Found - RTCC undocumented behaviour!!! — Parallax Forums

Found - RTCC undocumented behaviour!!!

sounddezignsounddezign Posts: 9
edited 2008-04-04 14:01 in General Discussion
We are launching a new product that uses SX28 micros and have encountered an undocumented feature of the SX that has been causing problems for the last week.

I am using the rtcc to count the number of instructions through pieces of code of different lengths so that it can be used to calculate how many more clocks are required to complete a set delay. The number of clocks to enter into the section of code is deterministic, so I set the rtcc to the value I want (mov rtcc,#7). I then let it run through the code before it comes to check the value of rtcc to see how much delay is left (mov w,rtcc). I have found that the rtcc stops counting after the "mov rtcc,#7" instruction. It will then recommence counting again after 4 instructions.

The code below shows where rtcc will read an incremented value. I just output the value to ra and rb to view the pins value.

mov    w,#7                
mov    rtcc,w                ;move rtcc with cycles since op0 was set                (1)
nop                        ;rtcc = 7 here
nop                        ;rtcc = 7 here
nop                        ;rtcc = 7 here
nop                        ;rtcc = 7 here
mov    w,rtcc                ;rtcc = 8 here (started counting again)
mov    isr_temp,w
mov    ra,isr_temp
swap    isr_temp
mov    m,#$0f
mov    !rb,#$f0
mov    rb,isr_temp
jmp    $-1




Any help or information as to why this occurs would be greatly appreciated. We need to understand the functionality of the SX28 fully for our time critical application.

Cheers,
Andy

Comments

  • pjvpjv Posts: 1,903
    edited 2008-04-03 15:40
    Hi Andy;

    A couple of things...

    Firstly I believe this is due to the pipeline architecture, but am not positive of that.
    Secondly, I do believe there is a very brief reference to this in the device spec sheetes, although I can't recall offhand exactly where. Third, this loss of ticks will happen any time you access the RTCC with instructions that operate in a "read-modify-write" manner, but not with those that work in a true "read" manner.
    Fourth, I thought that the number of lost counts was three, not four.
    Fifth, the IDE in debug will not always indicate the correct count in the RTCC, so please be aware of that. The method you are using; employing the I/O pins to indicate the value is a proper approach.

    Cheers,

    Peter (pjv)
  • BeanBean Posts: 8,129
    edited 2008-04-03 16:09
    Andy,
    I had a thread about this RTCC behavour but I cannot find it now.
    I think you lose 3 RTCC counts when you modify RTCC.
    I would suggest you just offset the value you assign to RTCC to account for this.
    Note that if the prescaler is used, the lost counts are different.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.iElectronicDesigns.com

    ·
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-04-03 17:05
    Bean (and pjv),

    The thread was located here...

    http://forums.parallax.com/showthread.php?p=708045

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • BeanBean Posts: 8,129
    edited 2008-04-03 17:11
    Thanks Chris.
    Yeah that was the thread I was looking for.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.iElectronicDesigns.com

    ·
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-04-03 17:56
    Hopefully it will provide the preliminary information required. In the mean time I am still trying to verify this on our end and possibly get it documented in a future revision.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • BeanBean Posts: 8,129
    edited 2008-04-03 18:49
    Chris,
    · As I point out in the original thread RTCC seems to act differently depending on the RTCC prescaler setting:
    ··· If the prescaler is 1:1 then 3 cycles are lost
    ··· If the prescaler is 1:2 or 1:4 then 5 cycles are lost
    ··· If the prescaler is 1:8 or higher then 1 cycle is lost (the cycle modifing RTCC doesn't get counted)

    Bean

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.iElectronicDesigns.com

    ·
  • sounddezignsounddezign Posts: 9
    edited 2008-04-04 13:35
    Thanks for the replies, glad to know that it's been observed before but could someone explain exactly why this happens as we need to fully understand this for our product. We are using the rtcc for current control on a device that controls currents anything up to 100Amps. If we get any misbehaviour of the SX, it could mean the whole device goes bang, or worse - the customers connected equipment.

    Cheers,
    Andy
  • BeanBean Posts: 8,129
    edited 2008-04-04 14:01
    Andy,
    · I cannot explain exactly WHY this happens. I know it has to do with the 4 stage pipe-line of instructions.
    · I think it is more important to know that it DOES happen and it IS predicable.

    · As long as you are not changing the RTCC precaler at runtime, you should only need to offset the value you putting into RTCC to account for the lost counts.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.iElectronicDesigns.com

    ·
Sign In or Register to comment.