我最近使用GPIO 引脚模拟IIC时序,发现GPIO_PTA3引脚的置位和清零语句的执行时间偏慢,需要0.8-1us左右: GPIO_PinSet(GPIO_PTA3); GPIO_PinClear(GPIO_PTA3);
我的程序主时钟40MHz,bus时钟为20MHz 测试主程序如下: int main (void) { uint32_t u32LoadValue0,u32LoadValue1; PIT_ConfigType sPITConfig0,sPITConfig1; PIT_ConfigType *pPIT_Config1 =&sPITConfig1; PIT_ConfigType *pPIT_Config0 =&sPITConfig0; /* Perform processor initialization */ sysinit(); /* IIC interface IO pin Initialize */ GPIO_Init(GPIOA,GPIO_PTA3_MASK, GPIO_PinOutput); GPIO_Init(GPIOA, GPIO_PTA2_MASK, GPIO_PinOutput); GPIO_Init(GPIOA,GPIO_PTB3_MASK, GPIO_PinOutput); printf("\nRunning the PIT_demo project.\n"); LED0_Init(); /* configure PIT module in chain mode */ /* PIT clock source is bus clock,20MHz */ /* PIT channel 0 load value = (1000000-1), channel 1 load value = (20-1)*/ u32LoadValue0 = 0xF423F; /*!< PIT ch0 timer loadvalue */ u32LoadValue1 = 0x13; /*!< PIT ch1 timer loadvalue */ /*configure PIT channel 1 in chain mode, enable interrupt and timer */ pPIT_Config1->u32LoadValue = u32LoadValue1; pPIT_Config1->bFreeze = FALSE; pPIT_Config1->bModuleDis = FALSE; /*!< enable PITmodule */ pPIT_Config1->bInterruptEn = TRUE; pPIT_Config1->bChainMode = TRUE; pPIT_Config1->bTimerEn = TRUE; /* configure PIT channel 0, only enable timer */ pPIT_Config0->u32LoadValue = u32LoadValue0; pPIT_Config0->bFreeze = FALSE; pPIT_Config0->bModuleDis = FALSE; /*!< enable PITmodule */ pPIT_Config0->bInterruptEn = FALSE; pPIT_Config0->bChainMode = FALSE; pPIT_Config0->bTimerEn = TRUE; PIT_Init(PIT_CHANNEL0, pPIT_Config0); PIT_Init(PIT_CHANNEL1, pPIT_Config1); PIT_SetCallback(PIT_CHANNEL1, PIT_Task); /* echo chars received from terminal */ GPIO_PinSet(GPIO_PTC5); while(1) { GPIO_PinSet(GPIO_PTA3); GPIO_PinClear(GPIO_PTA3); GPIO_PinSet(GPIO_PTA3); GPIO_PinClear(GPIO_PTA3); GPIO_PinSet(GPIO_PTA3); GPIO_PinClear(GPIO_PTA3); GPIO_PinSet(GPIO_PTA3); GPIO_PinClear(GPIO_PTA3); GPIO_PinSet(GPIO_PTA3); GPIO_PinClear(GPIO_PTA3); GPIO_PinSet(GPIO_PTA3); GPIO_PinClear(GPIO_PTA3); } }
|