Searching \ for '[SX] Simple demo of interupt triggered by RTCC - f' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/ubicom/sxints.htm?key=rtcc
Search entire site for: 'Simple demo of interupt triggered by RTCC - f'.

Exact match. Not showing close matches.
PICList Thread
'[SX] Simple demo of interupt triggered by RTCC - f'
2006\04\12@152434 by John Kauffmann/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, John Kauffman wrote:

File is self-explanatory, I think.
Symptom: LED stays on.



' =========================================================================
'
'   File...... INT-RTCC-01.SXB
'   Purpose... Demonstrate simple use of interupt triggered by RTCC
'   Author.... John Kauffman
'   E-mail....
'   Started...
'   Updated... 2006 04Apr 12 - 17:42
'
' =========================================================================

' -------------------------------------------------------------------------
' Program Description
' -------------------------------------------------------------------------
' Purpose = Demonstrate simple use of interupt triggered by RTCC
' objective: divide down RTCC interupts until one flash per 4 seconds.
' 4,000,000 / 256 / 256 / 256 = 0.25 = once per 4 seconds.
' RTCC prescaler set to 256
' INterupt increments ISRCOunter by 1
' In MAIN program when ISRCOUnter = 255 then increment ISRMultiplier1
' In MAIN program when ISRMultiplier1 = 255 then increment ISRMultiplier2
' When ISRMultiplier2 gets to 255 LED flashes
' -------------------------------------------------------------------------
' Device Settings
' -------------------------------------------------------------------------
DEVICE          SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
FREQ            4_000_000
' -------------------------------------------------------------------------
' IO Pins
' -------------------------------------------------------------------------
LED  VAR RC.0   
' LED circuit:
' RC.0 - 470ohm - LEDcath - LEDanode - Vdd
' -------------------------------------------------------------------------
' Constants
' -------------------------------------------------------------------------

' -------------------------------------------------------------------------
' Variables
' -------------------------------------------------------------------------
ISRCounter VAR byte
ISRMultiplier1 VAR byte
ISRMultiplier2 VAR byte

' =========================================================================
INTERRUPT
ISR_Start:
ISRCounter = ISRCounter + 1
ISR_Exit:
 RETURNINT ' {cycles}                                
' =========================================================================
PROGRAM Start
Start:
'Pin      76543210
' Following line sets only RC.0 (LED) to be an output
TRIS_C = $11111110 'Alternate = $FE
OPTION = $100000111
'bit      76543210
' option bits (left-7 to right-0)
' RTW 1 = RTCC ( not W)
' RTI 0 = RTCC roll-over interupt is enabled
' RTS 0 = Increment is form internal cycle (not expternal pin)
' RTE 0 = Increments on low to high transition (should have no effect since not on pin
' PSA 0 = Prescaler assigned to RTCC (not W)
' 1 = Prescaler = 1:256
' 1 = Prescaler = 1:256
' 1 = Prescaler = 1:256
Main:
' 4_000_000 / 256 / 256 /256 = 0.238 = once per 4 seconds
' first divide by 256 is in prescaler
IF ISRCOUnter = 255 Then
 ISRMultiplier1 = ISRMultiplier1+1
 IF ISRMultiplier1 = 255 THen
     ISRMultiplier2 = ISRMultiplier2+1
     IF ISRMultiplier2 = 255 THen
HIGH LED
Pause 500
LOW LED
     Endif
 Endif
Endif
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=120370
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\04\12@162559 by beann/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, bean wrote:

John, John.. You must be in a rush.

TRIS_C = $11111110 'Alternate = $FE
OPTION = $100000111
Binary numbers must be preceeded with a "%" not a "$".
Your OPTION value has 9 bits.

Bean.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=120370#m120383
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\04\12@183601 by John Kauffmann/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, John Kauffman wrote:

Yes, those were dumb mistakes. Works like a charm now. I feel a lot more comfortable about using RTCC-timed ISR. Thanks.

If I'm using the RTCC to generate relatively long times betwee pulses (like 1-100 seconds) is it correct in the ISR only set the prescalar high and do just a simple variable increment in the interupt and then do the scale-up looping in Main? In other words, would it be better to move that scaling into the interupt?

I'm a little perplexed by the result. I'm getting a flash every 3.8 seconds when I expected every 4.2 seconds. I can't imagine anything happening in processing at an SX's speed that is using up .4 seconds. Anyhow, the RTCC should kick in regardless of what is happening in main, that is the idea of an interupt.

Sources: ??
Internal timer is off by 11%
My math is wrong?
PAUSE 500 is having an effect on the RCTT?

I'm also having problems finding in the literature when the RTCC is set to zero. Assuming prescaler of 1:1, does that always happen on the next cycle after count 255, regardless of the execution being in ISR or MAIN and regardless of what command is being executed (understanding, of course, that some commands take several cycles ot complete).


Next step is to count the flashes and have the count show up on my four digit display.
Then I want to get the timing solved and get an exact 0.010 second count going in the display
Last, I want the display timer to start and end with closing of switches.
Then I will have a timer for the elapse between switch-closing events lasting 0 to 99 seconds displayed to 0.01 seconds.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=120370#m120395
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\04\13@042655 by beann/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, bean wrote:

John,
 Yes, Usually the scaling is done in the interrupt. I normally have the interrupt to ALL the work, but if you need cooperation, have the main program clear a flag, then have the interrupt SET the flag after the time has been reached. The main program will look the flag to be set, then perform whatever action, then clear the flag again.  
 
 Also you should check for the counters being zero instead of 255.  When they reach 255 that is only dividing by 255 NOT 256.

 IF ISRCOUnter = 0 Then
   ISRMultiplier1 = ISRMultiplier1 + 1
   IF ISRMultiplier1 = 0 Then
 PAUSE will not affect RTCC adversely.

 RTCC will be zero the very next cycle after it is 255. When the very first interrupt instruction is executed RTCC is 3. (Remember SX/B does some housekeeping for interrupts so RTCC will be > 3 when the first SX/B instruction is executed).

 John, as for the display (I'm assuming you mean the HC4LED display from me), keep each digit as a seperate variable. This eliminates the need to decode the digits. Something like
Digits VAR Byte (4)
INC Digits(0)
IF Digits(0) = 10 THEN
 Digits(0) = 0
 INC Digits(1)
 IF Digits(1) = 10 THEN
 Digits(1) = 0
 INC Digits(2)
 ' And so on...

Bean.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=120370#m120435
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

More... (looser matching)
- Last day of these posts
- In 2006 , 2007 only
- Today
- New search...