Shop OBEX P1 Docs P2 Docs Learn Events
Returnint Cycles not working with my RTCC rollover — Parallax Forums

Returnint Cycles not working with my RTCC rollover

gtslabsgtslabs Posts: 40
edited 2007-12-17 17:22 in General Discussion
I am having trouble getting the Interrupt to cycle correctly using RETURNINT 196.
I had to put the code RTCC=196 at the end of my interrupt code. I thought the RETURNINT (cycles)
was supposed to cover that.· I tried setting OPTIONX in the device but it said it was obsolete.

I am pulsing my RTCC pin and every 60 pulses I want to increment my counter.
I set my Option to rollover enabled on RTCC pin.

DEVICE          SX48, OSCXT2,BOR42
FREQ            4_000_000
Counter VAR Word

  INTERRUPT 
     Counter = Counter+1
     RTCC=196
  RETURNINT '196 'Not working {60 cycles}                                 

  PROGRAM Start

Start:
OPTION = %10100000
'RTW=1, RTI=0, RTS=1, RTE=0, PSA=0
RTCC = 196
Main:
  ' main code here
If RA.1 = 1 then 
  OPTION = %11100000 ' Disable Rollover
  'RTW=1, RTI=0, RTS=1, RTE=0, PSA=0
else
   OPTION = %10100000 'Enable Rollover
  'RTW=1, RTI=1, RTS=1, RTE=0, PSA=0
endif 
GOTO Main

Comments

  • DuctapemasterDuctapemaster Posts: 90
    edited 2007-12-16 05:23
    I believe that you need to add this formatting to your code:

    ISR_Start:
    ' Interrupt code here

    ISR_Exit:
    RETURNINT
  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2007-12-16 06:16
    It is my understanding that you need to set the STACKX and/or OPTIONX fuses to enable RTCC interrupts on rollover. Both STACKX and OPTIONX are valid device settings so try to enable them again. If it still does not work, mention the compiler and version number you are using.

    - Sparks
  • gtslabsgtslabs Posts: 40
    edited 2007-12-16 12:31
    Sparks, the SX Key manual shows them as valid for the SX28 but not for the SX48.
    Ductapemaster, that code did not help.

    I did find it to work with using "Returnint 60"
    I thought it counts up to 255 then rolls over.

    In any case I was trying to disable the RTCC counter but my options only disabled the rollover.
    This was going to be a roundabout way to disable pulse counting.
    I use the following to generate steps:

    TIMER1 PRESCALE, 6 ' 1:64
    TIMER1 PWM, tmpW1, tmpW2 ' activate PWM

    How can I disable this during runtime? I tried sending it a 0 but it locks up.
  • BeanBean Posts: 8,129
    edited 2007-12-16 14:32
    gtslabs,
    Yes "RETURNINT 60" would be correct. The compiler computes the correct adjustment to RTCC.

    TURBO, OPTIONX, and STACKX are not valid for the SX48 (they are alway on).

    I don't understand how using TIMER1 in PWM mode will prevent RTCC from incrementing ???
    I would connect your pulse though a resistor, then connect RTCC pin to an I/O pin. When the I/O pin is an input RTCC will count, if you make the I/O pin HIGH or LOW, if will prevent RTCC from counting.

    Bean.

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

    ·
  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2007-12-17 17:22
    Gtslabs,

    Sorry, sorry... It looks like you are correct about OPTIONX and STACKX not being valid settings for the SX48. They are always active on the 48 and can not be disabled. Please accept my apology for presenting incorrect information.

    I have now learned something I either forgot or did not know before. (I am not sure which is the actual case since I have occasionally used the SX48 by assuming these fuses were active without specifically setting them.)

    - Sparks
Sign In or Register to comment.