Maybe my working code fragments will help you. I have CAP1.0 and CAP1.1 connected
together, one for capture rising edge, another for falling edge. So I can measure pulse
duration with a 1/60 us resolution.
// Function of Pins P0.0 - P0.1
//PINSEL0
#define F00 (1 << 0*2) /* TXD0 */
#define F01 (1 << 1*2) /* RXD0 */
#define F04 (1 << 4*2) /* SCK */
#define F05 (1 << 5*2) /* MISO */
#define F06 (1 << 6*2) /* MOSI */
#define F07 (1 << 7*2) /* SS0 necessary even for Master */
#define F08 (1 << 8*2) /* TXD1 */
#define F09 (1 << 9*2) /* RXD1 */
#define F10 (2 << 10*2) /* CAPTURE1.0 */
#define F11 (2 << 11*2) /* CAPTURE1.1 */
#define PINSEL0init (F00 | F01 | F04 | F05 | F06 | F07 | F08 | F09 | F10 | F11)
.....
void InitController()
{
PINSEL0 = PINSEL0init;
PINSEL1 = PINSEL1init;
PINSEL2 &= 0xFFFFFFF0;
IODIR0 = OUTPUTS0;
IODIR1 = 0xFF0000;
T1PR = T1Prescaler - 1;
T1CCR = 0xA; // CAP1.1 - rising, CAP1.0 falling
T1TCR = 0x1; // Enable Timer 1
IOCLR1 = 0xFF0000;
}
......
// The sequence should always be: falling, rising
falling = T1CR0;
rising = T1CR1;
while (1) {
if ((T1CR1 != rising) && (T1CR0 != falling)) {
falling = T1CR0;
rising = T1CR1;
duration = falling - rising;
.....
}
The same free running timer1 can be used for a lot of other tasks too.
Best regards,
Varuzhan
----- Original Message -----
From: Lasse Madsen
To: lpc2000@yahoogroups.com
Sent: Wednesday, February 23, 2005 8:26 PM
Subject: [lpc2000] LPC2129 - Capture help requested :)
Hi all
I'm sitting with the MCB2100 from Keil trying to get the capture input
CAP1,0 & CAP1,1 to work (P0.10 and P0.11)
I have used the following code to make the inputs capture friendly...
PINSEL0&=0xFFAFFFFF;
T1CCR=0x1B; // I would like to capture both falling and rising edge on
both pins...
As you can see from the T1CCR i have set it for no interrupt (i would like
to do this but i cant figure out how to do interrupts in keil)
Im running with a 12MHz crystal and the frequency on both inputs which i
wish to capture is 250Hz (i would like to get the dutycycle variation)
Can any one help me setting up the registers im kinda lost or give me some
hints...
Best regards
Lasse Madsen
------------------------------------------------------------------------------
Yahoo! Groups Links
a.. To visit your group on the web, go to:
http://groups.yahoo.com/group/lpc2000/
b.. To unsubscribe from this group, send an email to:
lpc2000-unsubscribe@yahoogroups.com
c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
[Non-text portions of this message have been removed]Message
Re: [lpc2000] LPC2129 - Capture help requested :)
2005-02-23 by Varuzhan Danielyan
Attachments
- No local attachments were found for this message.