Searching \ for 'Capture/Compare/PWM on 16C76 ??' 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/ios.htm?key=pwm
Search entire site for: 'Capture/Compare/PWM on 16C76 ??'.

Truncated match.
PICList Thread
'Capture/Compare/PWM on 16C76 ??'
1998\06\16@073128 by Pavel Korensky

flavicon
face
Hello,

just one thing to ask. I would like to use the capture pins on 16C76.
Problem is, that I need to capture the following sequence:

rising edge, falling edge, raising edge

and measure time between first rising edge to falling edge and between
first rising edge to second rising edge. Actually, this is a measurement of
PWM duty cycle.

Problem is, that capture units can be programmed only as either raising or
falling edge interrupt. Is it possible to use following sequence (I suppose
that PWM cycle is slow enough and I have plenty of time)

1. Program Capture unit for event on rising edge
2. Capture rising edge
3. Program unit for event on falling edge
4. Capture falling edge
5. Program unit for event on raising edge
6. Capture rising edge
7. Do some calculations

The 16C7X datasheet is not very helpfull. I am not able to figure out if
this will work.

Thx for any info.

PavelK


**************************************************************************
* Pavel Korensky                                                         *
* DATOR3 LAN Services spol. s r.o.                                       *
* Modranska 1895/17, 143 00, Prague 4, Czech Republic                    *
*                                                                        *
* PGP Key fingerprint:  F3 E1 AE BC 34 18 CB A6  CC D0 DA 9E 79 03 41 D4 *
*                                                                        *
* SUMMA SCIENTIA - NIHIL SCIRE                                           *
**************************************************************************

1998\06\16@112017 by Andy Kunz

flavicon
face
>1. Program Capture unit for event on rising edge
>2. Capture rising edge
>3. Program unit for event on falling edge
>4. Capture falling edge
>5. Program unit for event on raising edge
>6. Capture rising edge
>7. Do some calculations

Yes, I've used it to measure both frame rate and positive or negative pulse
widths all at the same time.

Andy


==================================================================
Andy Kunz - Statistical Research, Inc. - Westfield, New Jersey USA
==================================================================

1998\06\17@041308 by Dr. Imre Bartfai

flavicon
face
Hello Pavel,
if you have a plenty of time, why not try the following:

1. Capture rising edge, enter ISR, read timer for LOW
2. Wait here until falling edge
3. Read time for HIGH, reset timer, leave ISR
4. Do what do you want until 1.

Of course, if your duty cycle nears 100% it may be a bottleneck...

Imre

On Tue, 16 Jun 1998, Pavel Korensky wrote:

{Quote hidden}

1998\06\17@070312 by Pavel Korensky

flavicon
face
At 08:03 17.6.1998 +0200, you wrote:
>Hello Pavel,
>if you have a plenty of time, why not try the following:
>
>1. Capture rising edge, enter ISR, read timer for LOW
>2. Wait here until falling edge
>3. Read time for HIGH, reset timer, leave ISR
>4. Do what do you want until 1.
>
>Of course, if your duty cycle nears 100% it may be a bottleneck...

Hmm, problem is,that there is a lot of other interrupts, some of them
should be as precisely timed as possible. On the processor with normal
architecture, like Z80(accessible stack in main memory) is not a problem to
write reentrant interrupt service or there are several interrupt vectors.
But on PIC it is impossible. And because PWM cycle is relatively slow, I
can't afford to be in the interrupt routine so long.
But, thank you for help.

PavelK


**************************************************************************
* Pavel Korensky                                                         *
* DATOR3 LAN Services spol. s r.o.                                       *
* Modranska 1895/17, 143 00, Prague 4, Czech Republic                    *
*                                                                        *
* PGP Key fingerprint:  F3 E1 AE BC 34 18 CB A6  CC D0 DA 9E 79 03 41 D4 *
*                                                                        *
* SUMMA SCIENTIA - NIHIL SCIRE                                           *
**************************************************************************

1998\06\20@023802 by Josef Hanzal

flavicon
face
>Hmm, problem is,that there is a lot of other interrupts, some of them
>should be as precisely timed as possible. On the processor with normal
>architecture, like Z80(accessible stack in main memory) is not a problem to
>write reentrant interrupt service or there are several interrupt vectors.
>But on PIC it is impossible.

Your original question has already been solved, I guess, but regarding
nested interrupts - although I did not try it yet, IMHO reentrant interrupt
is possible, of course limited by stack and other resources. To preserve
status and W registers, you have to dedicate more memory and still there
will be short moments, when interrupts are disabled. Well, Sinclair is a
different beast... ;-)

Josef

1998\06\22@083312 by Pavel Korensky

flavicon
face
At 08:40 20.6.1998 +0200, you wrote:
>>Hmm, problem is,that there is a lot of other interrupts, some of them
>>should be as precisely timed as possible. On the processor with normal
>>architecture, like Z80(accessible stack in main memory) is not a problem to
>>write reentrant interrupt service or there are several interrupt vectors.
>>But on PIC it is impossible.
>
>Your original question has already been solved, I guess, but regarding
>nested interrupts - although I did not try it yet, IMHO reentrant interrupt
>is possible, of course limited by stack and other resources. To preserve
>status and W registers, you have to dedicate more memory and still there
>will be short moments, when interrupts are disabled. Well, Sinclair is a
>different beast... ;-)

Nice idea... I will try to think about reentrant interrupts on PIC. It
should work with simulated SP in memory.

PavelK

**************************************************************************
* Pavel Korensky                                                         *
* DATOR3 LAN Services spol. s r.o.                                       *
* Modranska 1895/17, 143 00, Prague 4, Czech Republic                    *
*                                                                        *
* PGP Key fingerprint:  F3 E1 AE BC 34 18 CB A6  CC D0 DA 9E 79 03 41 D4 *
*                                                                        *
* SUMMA SCIENTIA - NIHIL SCIRE                                           *
**************************************************************************

1998\06\22@094531 by Andy Kunz

flavicon
face
>Hmm, problem is,that there is a lot of other interrupts, some of them
>should be as precisely timed as possible. On the processor with normal
>architecture, like Z80(accessible stack in main memory) is not a problem to
>write reentrant interrupt service or there are several interrupt vectors.
>But on PIC it is impossible.

No, it's quite possible.  You just need to implement a software stack, and
understand what is happening.

I solve the problem (most of the time) by putting a loop in my ISR:

void static interupt ISR (void)
       {
       static bit      DoLoop;

loop:   DoLoop = FALSE;
       if (RBIF)
               {
               ...
               RBIF = 0;
               DoLoop = TRUE;
               }
       if (other interrupts...)
               {
               ...
               DoLoop = TRUE;
               }
       if (DoLoop)
               goto loop;
       }


==================================================================
Andy Kunz - Statistical Research, Inc. - Westfield, New Jersey USA
==================================================================

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