查看: 2338|回复: 1

[求助] KE04单片机使用GPIO引脚置位和清零的指令执行时间较慢的问...

[复制链接]

该用户从未签到

2

主题

3

帖子

0

新手上路

Rank: 1

积分
22
最后登录
1970-1-1
发表于 2016-3-15 11:54:25 | 显示全部楼层 |阅读模式
我最近使用GPIO 引脚模拟IIC时序,发现GPIO_PTA3引脚的置位和清零语句的执行时间偏慢,需要0.8-1us左右:
                   GPIO_PinSet(GPIO_PTA3);
                   GPIO_PinClear(GPIO_PTA3);

我的程序主时钟40MHzbus时钟为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);
         }
}

我知道答案 目前已有1人回答
IMG_20160315_115159.jpg
回复

使用道具 举报

  • TA的每日心情
    开心
    2017-1-24 09:50
  • 签到天数: 2 天

    连续签到: 1 天

    [LV.1]初来乍到

    654

    主题

    3262

    帖子

    0

    金牌会员

    Rank: 6Rank: 6

    积分
    13128
    最后登录
    2019-1-27
    发表于 2016-3-15 13:58:17 | 显示全部楼层
    楼主,请不要重复发帖。
    回复 支持 反对

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /3 下一条

    Archiver|手机版|小黑屋|恩智浦技术社区

    GMT+8, 2025-7-22 20:29 , Processed in 0.088783 second(s), 23 queries , MemCache On.

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.

    快速回复 返回顶部 返回列表