Searching \ for 'Compare Interrupt' 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: 'Compare Interrupt'.

Truncated match.
PICList Thread
'Compare Interrupt'
1997\11\10@025748 by Dave Celsnak

flavicon
face
HELP!

I have posted before, and I will post it again....
I am having a hack of a time getting my interrupt to work properly!!!

No problems with entering the interrupt. The PIC reaches the routine just
fine.   I am using the Compare mode, to set a software interrupt on a
match (16 bit Compare Value to the 16 bit free-running Timer1).

The problem seems to be the actual service routine itself.
All I want to do is 'toggle' an I/O pin.  High on a match, then
low on the next match....Also, I am guessing this is the best location to
clear the Timer, and load the Compare Value with the latest (quite
possibly the same) value that is the next Period for the frequency I need.

READ:  Adjustable frequency driver via Compare Mode.  I hope this can
start a small thread, as I am always looking for a better way to skin this
cat.

Thank you,
Dave Celsnak

1997\11\10@030616 by tjaart

flavicon
face
Dave Celsnak wrote:
{Quote hidden}

Which timer/chip are you using?

--
Friendly Regards

Tjaart van der Walt
spam_OUTtjaartTakeThisOuTspamwasp.co.za
_____________________________________________________________
| WASP International http://www.wasp.co.za/~tjaart/index.html |
|       R&D Engineer : GSM peripheral services development    |
|   Vehicle tracking | Telemetry systems | GSM data transfer  |
|    Voice : +27-(0)11-622-8686 | Fax : +27-(0)11-622-8973    |
|              WGS-84 : 26010.52'S 28006.19'E                 |
|_____________________________________________________________|

1997\11\10@130349 by Eric van Es

flavicon
face
Dave Celsnak wrote:

> I have posted before, and I will post it again....
> I am having a hack of a time getting my interrupt to work properly!!!
>
> No problems with entering the interrupt. The PIC reaches the routine just
> fine.   I am using the Compare mode, to set a software interrupt on a
> match (16 bit Compare Value to the 16 bit free-running Timer1).

What is Compare mode? I assume you do some xor's to compare the timer and your
16bit value?

> The problem seems to be the actual service routine itself.
> All I want to do is 'toggle' an I/O pin.  High on a match, then
> low on the next match....Also, I am guessing this is the best location to
> clear the Timer, and load the Compare Value with the latest (quite
> possibly the same) value that is the next Period for the frequency I need.

I think that your problem lies with the clearing of the timer. There is an
interrupt for the timer's roll-over (at least on a 16c84). If you have all the
interrupts enabled you could get some funny reactions....

Do you clear your flags when you leave the interrupt routine? If not it could
trigger another interrupt. Is your interrupt routine at 0x04?

>I hope this can start a small thread, as I am always looking for a better way
to skin this
>cat.

You can hope all you like, but don't try forcing this to happen. People will
answer when they think they can help you - not because they are forced to!

Cheers! ...and good luck!


--
Eric van Es               | Cape Town, South Africa
.....vanesKILLspamspam@spam@ilink.nis.za | http://www.nis.za/~vanes
LOOKING FOR TEMPORARY / HOLIDAY ACCOMODATION?
http://www.nis.za/~vanes/accom.htm

1997\11\10@153826 by Harold Hallikainen

picon face
Dave,

       Sorry I haven't been more help on this.  It's always fun trying
to debug someone else's code when you can't run it thru an emulator or
simulator.  Have you managed to get MPLAB running?  Can you see what's
going wrong?

Harold

1997\11\10@183746 by Eric Naus

picon face
I don't know if I can help but check out my interrupt code at my website

http://webhome.idirect.com/~bine

It may be that you are staying too long in the interrupt routine or

you may not be exiting properly.

Have Fun

Eric Naus


At 02:55 AM 11/10/97 -0500, you wrote:
{Quote hidden}

1997\11\16@062355 by paulb

flavicon
face
Dave Celsnak wrote:

> I am using the Compare mode, to set a software interrupt on a
> match (16 bit Compare Value to the 16 bit free-running Timer1).

> Also, I am guessing this is the best location to clear the Timer, and
> load the Compare Value with the latest (quite possibly the same) value
> that is the next Period for the frequency I need.

 I think this is the problem.  While I could be wrong, I think Dave has
misunderstood how the Compare system works.  The WHOLE IDEA of the
Compare system is to AVOID altering the timer value itself.  In fact,
you do not even bother to READ the timer!  This is also what makes it
possible to execute multiple timing functions with only one timer/
counter.

 What you do in the ISR (as well as clear the interrupt flag and
execute your output function) is to read the Compare register, add to
this value the delay to the next Compare event (which delay is your
event period) and write this back into the Compare register.

 It is advisable, but probably not essential, to disable the interrupt
until the new value is fully written although the Compare register may
provide a facility for ignoring spurious compare matches in between the
two byte writes.  In any case, it is probably simple enough to update
the Compare register first, THEN clear the interrupt flag.

 It would go without saying that you check that any individual event
period is not shorter than the duration of the interrupt service
routine.  Considerable extra care must also be taken in writing a
routine for a time longer than the timer overflow.

 Cheers,
       Paul B.

1997\11\16@152719 by Dave Celsnak

flavicon
face
Thank you all for your help with the Compare Mode.
It seems I have figured out my problem.  Too many interrupts from the main
code.  I have a software 'serout' command that doesn't like to be
interrupted.

I had intended to use to compare module as a software solution to my
current hardware configuration of PWM thru an RC (analog out), then to a
Voltage-to-Frequency convertor.  The PWM that the PIC has doen't need to
cause interrupts.   Now I can refine my V/F convertor and achieve the
square waves I have been looking for.

Unless anyone can tell me why I should try to iron-out a software
frequency driver????
-Dave Celsnak
Senior, Western Michigan University
(Get me out of here, asap!)

1997\11\16@220817 by Mike Keitz

picon face
On Sun, 16 Nov 1997 15:25:29 -0500 Dave Celsnak <x93celsnakspamKILLspamWMICH.EDU>
writes:
>Thank you all for your help with the Compare Mode.
>It seems I have figured out my problem.  Too many interrupts from the
>main
>code.  I have a software 'serout' command that doesn't like to be
>interrupted.

Make the serial port run on a timer interrupt.  The main program would
service the CCP.  Without careful programming, there may be some
interruption in the output frequency when receiving and parsing serial
data, but the serial data is likely going to change the output frequency
anyway.

Or upgrade to a PIC containing a hardware USART.  If you're using 28-pin
ones already to get the CCP or PWM units, the USART ones will fit the
same socket.

If you only need an output function, the SSP found in most (all?) 28-pin
PICs could probably function to send asynchronous (7 bits anyway), by
writing the start bit as one of the data bits.  Not very useful to
receive asynchronous though.

[...]
> PWM thru an RC (analog out), then to
>a
>Voltage-to-Frequency convertor.
[...]
>Unless anyone can tell me why I should try to iron-out a software
>frequency driver????

Using a fully-digital method will ensure repeatability from unit to unit,
and accuracy of the output frequencies much higher than could be achieved
by your proposed method.   The hardware could be much simpler, likely
entirely within the PIC chip.  No adjustments other than maybe trimming
the crystal frequency (for very accurate output frequencies) would be
needed.

The PWM has only 256 or 1024 output steps.  The timer-compare method
could have about 64K (or 128K allowing for 1 extra count on one
half-cycle for inbetween steps) possible frequency settings between 7.6
Hz and 5 KHz.  Using a DDS method the frequency resolution could be
practically infinite, though phase noise would still be limited to about
1/64K.

Speaking of phase noise, it's going to be hard to keep the PWM frequency
from inducing a little FM on the output frequency.  When you change the
PWM setting, the output frequency will not change instantanously.  It
will take a long time to reach the final value due to the exponential
settling of the control-voltage filter.

These issues may not be problems though, depending on the requirements of
whatever is receiving the ouptut frequency.

1997\11\17@033253 by Dave Celsnak

flavicon
face
> [...]
> > PWM thru an RC (analog out), then to
> >a
> >Voltage-to-Frequency convertor. (Looking for ~0 to 5000 hz
> [...]
>
> Speaking of phase noise, it's going to be hard to keep the PWM frequency
> from inducing a little FM on the output frequency.  When you change the
> PWM setting, the output frequency will not change instantanously.  It
> will take a long time to reach the final value due to the exponential
> settling of the control-voltage filter.
>
> These issues may not be problems though, depending on the requirements of
> whatever is receiving the ouptut frequency.
>
The solution is turning out to be in hardware (V/F Convertor)
Maybe I should make my own DDS or NCO?
I could use a stand alone PIC that uses the same clock as my MAIN PIC.

There are a couple of ways to have the 2 PIC's talking.
Ideally,  the frequency output I desire is to be glitchfree, and
free-running,  with the ability to be constantly updated.

Any stabs at this idea?

-Dave Celsnak

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