Hello,
I have an Logomatic-v23 board from Sparkfun electronics. I want to use
an ADXL213AE accelerometer.
The ADXL send his PWM output value and i want to capture it using the
CAP0.0 input of the LPC2148. Unfortunately I have tried the following
code and it don't want to acquire the value.
Initialization :
1 | //Enable Interrupts
|
2 | VPBDIV=1; // Set PCLK equal to the System Clock
|
3 | VICIntSelect = ~(UART1_INT | RTC_INT | TIMER0_INT);
|
4 | VICVectCntl0 = 0x20 | 7; //Set up the UART1 interrupt
|
5 | VICVectAddr0 = (unsigned int)ISR_RxData1;
|
6 | VICVectCntl1 = 0x20 | 13; //Set up the RTC interrupt
|
7 | VICVectAddr1 = (unsigned int)ISR_RTC;
|
8 | VICVectCntl2 = 0x20 | 4; //Timer 0 Interrupt
|
9 | VICVectAddr2 = (unsigned int)ISR_Timer0;
|
10 |
|
11 | //TIMER0 setup
|
12 | T0TCR = 0x02; // TIMER0 Disable; reset T0TC & T0PC
|
13 | T0PR = 0x00000000; // Reset T0PR
|
14 | T0CTCR = 0x00; // Timer Mode: every rising PCLK edge
|
15 | T0CCR = 0x06; // Capture on CAPn.0 falling edge and Interrupt on CAPn.0 event
|
1 | static void ISR_Timer0(void)
|
2 | {
|
3 | //Interrupt Code Here
|
4 | T0TCR = 0x02; // TIMER0 Disable; reset T0TC & T0PC
|
5 | T0PR = 0x00000000; // Reset T0PR
|
6 |
|
7 | YPacc = T0CR0; //Get accelerometer captured value
|
8 |
|
9 | T0IR = 0xFF; //Clear the timer interrupt
|
10 | T0TCR = 0x01; // TIMER0 Enable
|
11 | VICVectAddr =0; //Update the VIC priorities
|
12 | }
|
Main code :
1 | rprintf_devopen(putc_serial0); //Init rprintf
|
2 | rprintf("ADXL2148 Accelerometer Yp raw data :\n\r");
|
3 |
|
4 | VICIntEnable |= TIMER0_INT; //Enable Timer0 Interrupts
|
5 | T0TCR = 0x01; // TIMER0 Enable
|
6 |
|
7 | while( 1 )
|
8 | {
|
9 | rprintf("T0CR0:%i\n\r",T0TC);
|
10 | }
|
Output on Hyperterminal :
1 | ADXL2148 Accelerometer Yp raw data :
|
2 | T0CR0:369396
|
3 | T0CR0:139755
|
4 | T0CR0:271646
|
5 | T0CR0:539757
|
6 | T0CR0:311754
|
And the value is never the same...
Does anybody could help me to find my problem?