Hi
I am assuming that this is also using a serial polling routine and
with numbers and space that you are sending out at 9600 baud (1ms per
character) you take about 11ms per string. Change it to an interrupt
type so you do not have to wait for the Txd. An alternative is to
boost the baud rate to like 57.6K or even 115.2K.
You should also change the capture to an interrupt to collect the time
and save it into a simple stack in case you get locked up waiting for
communications if you need to keep the baud rate at 9600.
regards,
Charles
--- In lpc2000@yahoogroups.com, "jase_ko" <jase.ko@...> wrote:
>
> Hi guys,
>
> We are after a bit of help with the LPC2124.
> We are trying to use the capture pin (CAP 0.2) to determine the
> speed of a vehicle based on the number of pulses we receive.
>
> We find that we are getting consistant stray outliers.
>
> Below is the source code we are using and the results we are getting
> to a terminal program.
>
> Any help would be ace.
>
> void main()
> {
>
> // init tick timer
> T0MR0 = 0xFFFFFFFF;
> T0MCR = 0x03;
>
> // Interrupt and Reset on MR0
> VICVectAddr2 = (unsigned long)IRQTickTimer; // set interrupt
> vector in 0
> VICVectCntl2 = 0x20 | 4; // use it for Timer 0 Interrupt
> VICIntEnable |= 0x00000010; // Enable Timer0 Interrupt
>
> // init capture
> PINSEL1 |= 0x00000003; // select capture pin on pin 16. (uses
> timer 0)
> T0CCR |= 0x00000040; // rising edge active (not falling
> edge)
> T0TCR = 0x00000001; // TC and PC are enabled for
> counting
> T0PR = 0x00000000;
>
>
> // init serial comms
> // Initialise the UART0 serial communications.
> PINSEL0 |= 0x00000005; // Enable RxD1 and TxD1
> U0LCR = 0x83; // 8N1 with DLAB enabled.
> U0DLL = 97; // 9600 Baud Rate @ 15MHz VPB Clock
> U0LCR = 0x03; // DLAB = 0
> U0FCR = 0xc7; // turn on fifo buffer
>
> // Initialise the UART1 serial communications.
> PINSEL0 |= 0x00050000; // Enable RxD1 and TxD1
> U1LCR = 0x83; // 8N1 with DLAB enabled.
> SetUART1BaudRate();
> U1LCR = 0x03; // DLAB = 0
>
>
> static unsigned long prevTC = 0;
> unsigned long currTC = T0CR2;
> unsigned long prevTicks = 0;
> // ssv1.speed.ticks is an unsigned long
>
> while (1)
> {
> currTC = T0CR2;
> if (currTC > prevTC)
> {
> ssv1.speed.ticks = currTC - prevTC;
> prevTC = currTC;
> SerialSendLongInt (ssv1.speed.ticks); SerialSendString (" ");
> SerialSendLongInt (ssv1.speed.ticks-prevTicks);
> SerialSendString ("\n");
> prevTicks = ssv1.speed.ticks;
> }
> }
> }
>
>
>
> Printout from the terminal
> 185078 -6
> 185085 7
> 185083 -2
> 185097 14
> 185096 -1
> 185056 -40
> 370182 185126
> 185082 -185100
> 185090 8
> 185068 -22
> 185088 20
> 185080 -8
> 185077 -3
> 185096 19
> 185105 9
> 185085 -20
> 185107 22
> 185108 1
> 185100 -8
> 185097 -3
> 185111 14
> 185099 -12
> 185112 13
> 185087 -25
> 185074 -13
> 370156 185082
> 185089 -185067
> 185096 7
> 185058 -38
> 185114 56
> 185088 -26
> 185095 7
> 185117 22
> 183515 -1602
> 371311 187796
> 555767 184456
> 185071 -370696
> 173318 -11753
>Message
Re: Capture pin inconsistencies
2006-02-14 by charlesgrenz
Attachments
- No local attachments were found for this message.