To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.handyboardOpen lugnet.robotics.handyboard in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / Handy Board / 7765
7764  |  7766
Subject: 
wits end with PWM measurement
Newsgroups: 
lugnet.robotics.handyboard
Date: 
Sat, 22 Apr 2000 12:53:03 GMT
Original-From: 
David Young <djyoung@voyager.co.nzANTISPAM>
Viewed: 
865 times
  
Dear All

I'm at my wits end on this one. It's a little routine to measure on PA0 a pulse
width of a PWM signal generated on PA7. The two pins are linked with a jumper.

I've looked through all the books and and handyboard archive, but all I get is
values that just don't seem to make sense.

Can anyone tell me where I'm going wrong.

TIA David young

void main()

{

int period=1500; /* High period for PWM signal on PA7 */

int TIC3 = 0x1014; /* TIC3 at $1014 and $1015 (connected to PA0) */

int TCTL2 = 0x1021; /* TCTL2 (input capture register) at $1021 */

int TFLG1 = 0x1023; /* TFLG1 (input capture flag register) at $1023 */

int rising_edge;

int falling_edge;

servo (period); /* PWM signal on PA7 - connected to PA0 by jumper */

servo_on ();



/* Detect a signal at PA0 on its rising edge -> set bit #0 to 1 and #1 to 0 */

bit_set(TCTL2,0);

bit_clear(TCTL2,1);

bit_set(TFLG1,0); /* Clear TFLG1 */

while (peek(TFLG1) & 0x01 != 0x01){} /* Loop until the capture flag for PA0 is
set*/

/* Get rising edge time in TIC3 */

rising_edge = peekword(TIC3);



/* Detect a signal at PA0 on its falling edge -> set bit #0 to 1 and #1 to 1 */

bit_clear(TCTL2,0);

bit_set(TCTL2,1);

bit_set(TFLG1,0); /* Clear TFLG1 */

while (peek(TFLG1) & 0x01 != 0x01) {} /* Loop until the capture flag for PA0 is
set*/

/* Get falling edge time in TIC3 */

falling_edge = peekword(TIC3);



printf("Pulse range = %d", rising_edge);

printf(" %d\n", falling_edge);

servo_off();

}



--
MIME ATTACHMENTS DISCARDED:

1.  Content-Type: text/html;
    charset="iso-8859-1"
    Content-Transfer-Encoding: quoted-printable
    Content-Length: 2344



1 Message in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR