[Diy_efi] GCC/ARM LPC21xx assist needed for Donegan ECM/EFI :-)
Steven P. Donegan
donegan
Sun Jan 14 15:52:44 UTC 2007
I need a fragment of code (or a completely usable piece of code) for the
following scenario:
Using the Capture/Compare and Timer functions, setup (CCP_Setup()) a CCP
register/pin with a timer such that future interrupts on that CCP will
support capturing the frequency in Hz on that CCP pin. The waveform is
expected to be 50% duty cycle.
My poor beginning on the interrupt handler follows:
/*
The short fragment of code below can be used to measure frequency on a
capture pin. Initialize FIQ_R8 to the timer address and FIQ_R9 to -1
and
enable the fast interrupt.
The frequency can be calculated with: (float)(PCLK * FIQ_R9) /
(float)(FIQ_R11 - FIQ_R10)
*/
void FastInterrupt(void) __attribute__((interrupt("FIQ"), naked));
void FastInterrupt(void)
{
asm volatile("ldr r12, [r8,0]\r\n"
"ldr r13, [r8,40]\r\n"
"str r12, [r8,0]\r\n"
"adds r9, r9, #1\r\n"
"moveq r10, r13\r\n"
"mov r11, r13\r\n"
"subs pc, lr, #4\r\n");
}
I know there are some ARM and C people out there - this is the first
fragment I need for the ECU - it is for reading a GM MAF.
TIA!
More information about the Diy_efi
mailing list