This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C123GH6PM PF0进不了中断问题求工程师解



uint16_t Image_V, Image_H;

volatile uint8_t send_flag = 0;
uint8_t Image_Data[ROW][COLUMN] = { 0 };

uint32_t ui32Status;
void Init_Camera()
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
HWREG(GPIO_PORTF_BASE + GPIO_O_CR) = 0xff;

HWREG(GPIO_PORTA_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
HWREG(GPIO_PORTA_BASE + GPIO_O_CR) = 0xff;

GPIOIntRegister(GPIO_PORTF_BASE, PORTFIntHandler);
GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_0); //使能摄像头控制管脚
GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_1); //使能摄像头控制管脚

GPIOPinTypeGPIOInput(GPIO_PORTA_BASE,GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 |
GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7); //使能摄像头数据管脚

GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_RISING_EDGE); //场中断上升沿触发
GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_RISING_EDGE); //行中断下降沿触发
IntEnable(INT_GPIOF);
GPIOIntEnable(GPIO_PORTF_BASE, GPIO_INT_PIN_1); //使能场中断
GPIOIntEnable(GPIO_PORTF_BASE, GPIO_INT_PIN_0);//使能行中断

IntMasterEnable();

}

void PORTFIntHandler(void)
{
static uint8_t cnt = 0;


LED_12;
ui32Status = GPIOIntStatus(GPIO_PORTF_BASE, true); // 获取中断状态

if (ui32Status == GPIO_INT_PIN_1) //场中断服务函数
{
LED_13;
cnt = 0;
GPIOIntClear(GPIO_PORTF_BASE, ui32Status);
GPIOIntEnable(GPIO_PORTF_BASE, GPIO_INT_PIN_0);//使能行中断
Image_V = 0; //图像行数清零
send_flag = 0;
}

if (ui32Status == GPIO_INT_PIN_0)
{
LED_1;
cnt++;
GPIOIntClear(GPIO_PORTF_BASE, ui32Status);
for (Image_H = 0; Image_H < COLUMN; Image_H++)
{
Image_Data[Image_V][Image_H] = HWREG(GPIO_PORTA_BASE + GPIO_O_DATA);
}
Image_V++;
if (Image_V > 50) {
send_flag = 1;
GPIOIntDisable(GPIO_PORTF_BASE, GPIO_INT_PIN_0); //使能行中断
}

}

}