LM4F231H5QR QEI功能 ph1A口 读不到脉冲?条件是phA1接入10-100KHZ的频率,

2019-03-24 11:10发布

 unsigned int i;
 signed   int j1=0,j0=0;
    //
    // The FPU should be enabled because some compilers will use floating-
    // point registers, even for non-floating-point code.  If the FPU is not
    // enabled this will cause a fault.  This also ensures that floating-
    // point operations could be added to this application and would work
    // correctly and use the hardware floating-point unit.  Finally, lazy
    // stacking is enabled for interrupt handlers.  This allows floating-
    // point instructions to be used within interrupt handlers, but at the
    // expense of extra stack usage.
    //
    //FPUEnable();
    //FPULazyStackingEnable();     //
    // Set the clocking to run directly from the crystal.
    //              
    SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |SYSCTL_XTAL_6MHZ);//80MHZ                    
     ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
 ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
 ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_QEI1);
 ROM_GPIOPinTypeQEI(GPIO_PORTC_BASE,GPIO_PIN_5);
  ROM_GPIOPinTypeQEI(GPIO_PORTG_BASE,GPIO_PIN_4);
 ROM_QEIConfigure(QEI1_BASE,(QEI_CONFIG_CAPTURE_A|QEI_CONFIG_NO_RESET|QEI_CONFIG_CLOCK_DIR|QEI_CONFIG_NO_SWAP),0);
 //* 设置速度检测周期为 0.01秒
 ROM_QEIVelocityConfigure(QEI1_BASE, QEI_VELDIV_1, 60000);      
  ROM_QEIEnable(QEI1_BASE);  
   ROM_QEIVelocityEnable(QEI1_BASE);
    // Loop forever while the timers run.
    while(1)
    {
     //*  读出上一个周期的速度计数值  */
     i = ROM_QEIVelocityGet(QEI1_BASE); 
     /*  转化为 转/分钟*/            
      i = (i*100*60)/(4*512);
     //读取当前方向   
      j1 = ROM_QEIDirectionGet(QEI1_BASE); 
     j1=j1;
    ROM_SysCtlDelay(150*(ROM_SysCtlClockGet()/3000));   //DELAY 150MS
  
       } 以上仿真时候i ,j1 没反映 ;为什么?请高人指点 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
2条回答
眼睛好累
2019-03-24 17:17
< :TI_MSP430_内容页_SA7 --> 我也遇到了类似的问题,就是在运行这一句的时候会卡死:QEIConfigure(QEI1_BASE,(QEI_CONFIG_CAPTURE_A|QEI_CONFIG_NO_RESET|QEI_CONFIG_CLOCK_DIR|QEI_CONFIG_NO_SWAP),0);能不能问一下你是怎么解决的

一周热门 更多>

相关问题

    相关文章