Searching \ for 'Interrupt with RA4/TOCI' 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/microchip/ints.htm?key=interrupt
Search entire site for: 'Interrupt with RA4/TOCI'.

Truncated match.
PICList Thread
'Interrupt with RA4/TOCI'
1998\01\20@091036 by Conor O'Rourke

flavicon
face
Hi all,

Quick question - I wanted to use a '84 in a project that had a databus.
No problems so far, the databus is 8 bits wide so I use RB0-7. Problem
now is I lose the INT pin. However, I thought of a way around it: If
I use the TOCI pin for interrupt and initialise the counter to FF, the
next edge will cause an overflow interrupt and I can use that. Does
that make sense? Are there any problems associated with this method?
(Yeah, I should really get off my butt and try it myself but I'm
far away from my equipment for the moment :-(....)

Conor.

1998\01\20@152432 by myke predko

flavicon
face
Conor O'Rourke wrote:

>Hi all,
>
>Quick question - I wanted to use a '84 in a project that had a databus.
>No problems so far, the databus is 8 bits wide so I use RB0-7. Problem
>now is I lose the INT pin. However, I thought of a way around it: If
>I use the TOCI pin for interrupt and initialise the counter to FF, the
>next edge will cause an overflow interrupt and I can use that. Does
>that make sense? Are there any problems associated with this method?
>(Yeah, I should really get off my butt and try it myself but I'm
>far away from my equipment for the moment :-(....)
>
>Conor.

This is a real interesting question and potentially very useful - either as
suggested if all eight bits of PortB is being used for a bus or in a Low-End
device which doesn't have interrupts (and you want to capture an incoming
line transition without Polling all the time).  For the Low-End devices this
could allow the TOCK1 line to be used as input.

Sorry for the long note, I've appended the code and stimulus file I created
in order to try out this idea.

When I looked at the problem, I knew I had to first load up the 2 cycle
synchronizer with a 1 along with TMR0 with 0x0FF (this is presuming that the
Prescaler is not used with TMR0).  Then, when the input transition came in,
TMR0 would be incremented and then the interrupt would be requested.

The code I came up with that interrupts on the first rising transition is:


title  "ClockIn - Use the Clock As a Interrupt Source."
;
;  This Program is designed for use ONLY in MPLAB.  When a rising edge is
;   received by the TOCK1 (RA4) Pin, the Timer is incremented.  Before Enabling
;   Interrupts, The /2 Counter is loaded with 1 and TMR0 is loaded with 0x0FF.
;
;  Let's see if this works in the Simulator.
;
;  Hardware Notes:
;   This Program is Meant to ONLY run in MPLAB
;   RB0 - RB1 is Assumed to be used elsewhere
;   RA4 is the Interrupt Input
;
;  Myke Predko
;  96.07.20
;
 LIST P=16F84, R=DEC
 errorlevel 0,-305
 errorlevel 1,-224                     ;  Ignore "option" Instruction Warnings
 INCLUDE "d:\mplab\P16F84.inc"

;  Registers/Variables

__CONFIG _CP_OFF & _XT_OSC & _PWRTE_ON  & _WDT_OFF
                               ;  Note that the WatchDog Timer is OFF

 PAGE
;  Code for ClockIn

 org    0

 goto   MainLine               ;  Skip Over Output Tables

 org    4
Int                             ;  Interrupt Handler

;  #### - There Should be Some Context Register Saving Here/Event Display

 goto   $                      ;  Infinite Loop When you Get Here


MainLine                        ;  Enable Interrupts with the Timer waiting for
                               ;   a Rising Edge

 movlw  B'11000000'            ;  First Setup with Instruction Clock as TMR0
 option                        ;   Source

 movlw  B'11100000'            ;  Option Setup For TOCK1 TMR0 Source

 clrf   TMR0                   ;  Set TMR0 to 0x0FF
 decf   TMR0

 option                        ;  Enable Timer on Outside Interrupt Edge
                               ;   NOTE - Executing this Instruction after
                               ;    "decf" will Load the Synchronizer with a
                               ;    "1"

 movlw  0x0A0                  ;  Enable TMR0 Overflow Interrupt
 movwf  INTCON

 goto   $                      ;  Loop Forever Waiting for the Interrupt

 end


The Stimulus File Used to Test this Program is:


!  CLOCKIN.STI - Test ClockIn Program
!
!  98.02.20
!
!  Myke Predko - This PIC Stimulus File is used to Input a Rising Edge into
!                 "ClockIn" to See if the Timer Input Pin can be used as a
!                 Interrupt on Input State.
!
Step    RA4
1       0              !  Starting, With Line Low
14       1              !  Make the Line High, Do we have an interrupt?
                       !  End of Test Stimulus File



I have *only* tested this on MPLAB 3.31.  I'll probably try it out tonight
on some hardware (although I'll have to make sure the rising edge I input
into TMR0 does not have any bouncing).


Any reasons why this code shouldn't work in hardware?


myke

"Programming and Customizing the PIC Microcontroller" is the January 1998
Electronics Book Club Main Selection.  See "http://www.myke.com".

1998\01\20@155654 by Douglas J.A.R.Sasse

flavicon
face
>When I looked at the problem, I knew I had to first load up the 2 cycle
>synchronizer with a 1 along with TMR0 with 0x0FF (this is presuming that the
>Prescaler is not used with TMR0).  Then, when the input transition came in,
>TMR0 would be incremented and then the interrupt would be requested.
>The code I came up with that interrupts on the first rising transition is:
> title  "ClockIn - Use the Clock As a Interrupt Source."
>;  This Program is designed for use ONLY in MPLAB.  When a rising edge is
>;   received by the TOCK1 (RA4) Pin, the Timer is incremented.  Before Enabling
>;   Interrupts, The /2 Counter is loaded with 1 and TMR0 is loaded with 0x0FF.
>;  Let's see if this works in the Simulator.
>;  Hardware Notes:
>;   This Program is Meant to ONLY run in MPLAB
>;   RB0 - RB1 is Assumed to be used elsewhere
>;   RA4 is the Interrupt Input
>;  Myke Predko
>;  96.07.20
>  LIST P=16F84, R=DEC
>  errorlevel 0,-305
>  errorlevel 1,-224                     ;  Ignore "option" Instruction Warnings
>  INCLUDE "d:\mplab\P16F84.inc"
 Registers/Variables
> __CONFIG _CP_OFF & _XT_OSC & _PWRTE_ON  & _WDT_OFF
                               ;  Note that the WatchDog Timer is OFF
{Quote hidden}

First Myke, Where or What is the ISB Number for the PIC Programming book?
also where Might i do a search (Hardware) for a GRiD Compass 1109 computer
(laptop) this has NO Floppy drive port's and uses Bubble Memmory for hard
drive's A-I and has a GPIB and a 19 pin Serial [ ******  ]
                                                        [ ******* ]
                                                        [  ****** ]
connector that look's like
a DB-15 with extra row of PIN'S in the SOCKETS
also there is a modem but no software to use it to down-load.
have to format and add the newer DOS (Has DOS 2.21 on it)
the thing run's HOT for a Lap-top but also there are no Battery's in it.
any idea for data, part's (I've tryed AST and National Part's (Radio Shack
Source)) with out any luck. would like to add more program's but first need
to get access to the GIPB and serial Wiring Diag.'s
How is your robot's comming?
thanks for your time.
please forward to anyone who might have one of these "Lap-top" or know's a
source for info.
they can E-mail or Snail-mail me direct (see sig. file)
Http://ic.mankato.mn.us/~douglas  <-LINK to Wirz Electronics&Dontronics
spam_OUTdouglasTakeThisOuTspamic.mankato.mn.us

Douglas J.A.R.Sasse
P.O.Box 1064
Mankato, Minnesota 56002
U.S.A.
-----------------------------------------------------------------
     MIDWINTER MADNESS
     National Sports Center
     Blaine, Minnesota
     Feb 14 at 7:30 A.M. C.S.T.
     $7.00 at the door (612)  537-1722 hot line info.
      first prize k5-133 w/16mb ram 1.7 gb hd 14" svga 12X cd rom system
      300 dealer in fle market an 80 vendors
--------------------------------------------------------------------

1998\01\21@094825 by myke predko

flavicon
face
Just as a follow up, I tried the TMR0 Interrupt Handler Code out last night
on a 16F84 and guess what?  It worked fine.

In the interrupt handler, I simply output a "0" on a bit to light an LED.

So, If you have a mid-range part and need a second interrupt pin or can't
use RB0, here you go.

Douglas J.A.R.Sasse asked:

>First Myke, Where or What is the ISB Number for the PIC Programming book?

Hardcopy: 0-07-913645-1
Softcopy: 0-07-913646-X

>also where Might i do a search (Hardware) for a GRiD Compass 1109 computer
>(laptop) this has NO Floppy drive port's and uses Bubble Memmory for hard
>drive's A-I and has a GPIB and a 19 pin Serial [ ******  ]
<SNIP>

No idea - maybe posting a request on one of the sci.electronics newsgroups
would give you some pointers.  An Alta-Vista search might yield something as
well.

Good Luck!

myke

"Programming and Customizing the PIC Microcontroller" is the January 1998
Electronics Book Club Main Selection.  See "http://www.myke.com".

1998\01\21@172608 by Conor O'Rourke

flavicon
face
Myke said:

> Just as a follow up, I tried the TMR0 Interrupt Handler Code out last night
> on a 16F84 and guess what?  It worked fine.
>
> In the interrupt handler, I simply output a "0" on a bit to light an LED.
>
> So, If you have a mid-range part and need a second interrupt pin or can't
> use RB0, here you go.

Whoa! Hey, I'm really impressed now. I didn't expect someone to actually
write code and try it out and everything. Might even buy your book
now <grin>.

Thanks again,

Conor.

--
Conor O'Rourke
x86 Driver Group
Sun Microsystems Ireland

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