Привожу ниже пример кода. Инициализация прерывания:
Код
DWORD EINTInit( void )
{
PINSEL4 = 0x00100000; /* set P2.10 as EINT0 and
P2.0~7 GPIO output */
FIO2DIR = 0x000000FF; /* port 2, bit 0~7 only */
FIO2CLR = 0x000000FF; /* turn off LEDs */
IO2_INT_EN_R = 0x200; /* Port2.10 is rising edge. */
EXTMODE = 1; /* INT0 edge trigger */
EXTPOLAR = 1; /* INT0 is rising edge by default */
EXTINT = 0xf; /* clear all external interrupts */
if ( install_irq( EINT0_INT, (void *)EINT0_Handler, HIGHEST_PRIORITY ) == FALSE )
{
return (FALSE);
}
return( TRUE );
}
{
PINSEL4 = 0x00100000; /* set P2.10 as EINT0 and
P2.0~7 GPIO output */
FIO2DIR = 0x000000FF; /* port 2, bit 0~7 only */
FIO2CLR = 0x000000FF; /* turn off LEDs */
IO2_INT_EN_R = 0x200; /* Port2.10 is rising edge. */
EXTMODE = 1; /* INT0 edge trigger */
EXTPOLAR = 1; /* INT0 is rising edge by default */
EXTINT = 0xf; /* clear all external interrupts */
if ( install_irq( EINT0_INT, (void *)EINT0_Handler, HIGHEST_PRIORITY ) == FALSE )
{
return (FALSE);
}
return( TRUE );
}
В обработчике прерывания я считываю данные с камеры TCMD8240
Код
//Get the cam data handler
void EINT0_Handler (void) __irq
{
BYTE res_data;
EXTINT = EINT0; /* clear interrupt */
IENABLE; /* handles nested interrupt */
eint0_counter++;
if ( (eint0_counter < MAX_FILE_SIZE)& isIrq ) /* less then max size of file */
{
/*we need to observe that VBLK and HBLK = 1*/
/*
0x08000000; P1.27=VBLK
0x10000000; P1.28=HBLK
//////////////////////////
0x00040000; P1.18=D0
0x00080000; P1.19=D1
0x00100000; P1.20=D2
0x00200000; P1.21=D3
0x00400000; P1.22=D4
0x00800000; P1.23=D5
0x01000000; P1.24=D6
0x02000000; P1.25=D7
*/
if(((FIO1PIN & 0x08000000)>>27)& ((FIO1PIN & 0x10000000)>>28))//reseive data
{
res_data = (BYTE)((FIO1PIN >>18) & 0xFF);
memset(Buff, res_data, 1);
res_1 = f_write(&file1, Buff, 1, &s2_1);
}
}
else if ( (eint0_counter >= MAX_FILE_SIZE)& isIrq ) /* we'll need close the file*/
{
put_rc(f_close(&file1));
isIrq = 0;
xputs("\nWritten OK!!!");
}
IDISABLE;
VICVectAddr = 0; /* Acknowledge Interrupt */
}
void EINT0_Handler (void) __irq
{
BYTE res_data;
EXTINT = EINT0; /* clear interrupt */
IENABLE; /* handles nested interrupt */
eint0_counter++;
if ( (eint0_counter < MAX_FILE_SIZE)& isIrq ) /* less then max size of file */
{
/*we need to observe that VBLK and HBLK = 1*/
/*
0x08000000; P1.27=VBLK
0x10000000; P1.28=HBLK
//////////////////////////
0x00040000; P1.18=D0
0x00080000; P1.19=D1
0x00100000; P1.20=D2
0x00200000; P1.21=D3
0x00400000; P1.22=D4
0x00800000; P1.23=D5
0x01000000; P1.24=D6
0x02000000; P1.25=D7
*/
if(((FIO1PIN & 0x08000000)>>27)& ((FIO1PIN & 0x10000000)>>28))//reseive data
{
res_data = (BYTE)((FIO1PIN >>18) & 0xFF);
memset(Buff, res_data, 1);
res_1 = f_write(&file1, Buff, 1, &s2_1);
}
}
else if ( (eint0_counter >= MAX_FILE_SIZE)& isIrq ) /* we'll need close the file*/
{
put_rc(f_close(&file1));
isIrq = 0;
xputs("\nWritten OK!!!");
}
IDISABLE;
VICVectAddr = 0; /* Acknowledge Interrupt */
}
В общем в результате выполнения этого кода, прерывание срабатывает все таки по низкому уровню (по спаду) а не по фронту.
PS: Инвертор на вход МК ставить не имеется возможности потому и пытаюсь решить проблему с прерыванием по фронту