TMS320F28335 eQEP模块,计算外部增量式编码器脉冲数,QPOSCNT的值一直为0
确定有脉冲输入,但没有捕获到,怀疑是哪配置有问题,但用ti官网的程序,也是同样的问题。具体配置程序如下:
InitEQep1Gpio();
#if (CPU_FRQ_150MHZ)
EQep1Regs.QUPRD = 1500000; // Unit Timer for 100Hz at 150 MHz SYSCLKOUT =10ms
#endif //ÔÚ150MHzϵͳʱÖÓϲúÉú100HzµÄµ¥Î»Ê±¼äÖµ£¬¼´ÈÃqep10ms²úÉúÒ»´ÎtimeoutÖжÏ
#if (CPU_FRQ_100MHZ)
EQep1Regs.QUPRD = 1000000; // Unit Timer for 100Hz at 100 MHz SYSCLKOUT
#endif
EQep1Regs.QPOSCNT = 0;
EQep1Regs.QDECCTL.bit.QSRC = 0; // QEP quadrature count mode Çó»ý¼ÆÊýģʽ:²úÉú·½ÏòºÍ4±¶ÆµµÄʱÖÓ
EQep1Regs.QDECCTL.bit.XCR = 0; // 2x resolution (cnt falling and rising edges)
EQep1Regs.QDECCTL.bit.SWAP = 0;
EQep1Regs.QDECCTL.bit.IGATE = 0; //¸ÃλÖÃ1ºó£¬Á¬Ë÷ÒýÂö³å¶¼¹ýÂËÁË
EQep1Regs.QDECCTL.bit.QAP = 0;
EQep1Regs.QDECCTL.bit.QBP = 0;
EQep1Regs.QDECCTL.bit.QIP = 0;
EQep1Regs.QDECCTL.bit.QSP = 0;
EQep1Regs.QEPCTL.bit.FREE_SOFT = 2; //×ÔÈ»µØ¶¯×÷
EQep1Regs.QEPCTL.bit.PCRM = 01; // ÿ´ÎË÷Òýʼþ²úÉúʱQPOSCNT¸´Î»
// EQep1Regs.QEPCTL.bit.PCRM=01; // ×î´ó¼ÆÊýλÖÃʱQPOSCNT¸´Î»
EQep1Regs.QEPCTL.bit.UTE = 1; // Unit Timeout Enable ʹÄܵ¥Î»¶¨Ê±Æ÷
EQep1Regs.QEPCTL.bit.QCLM = 1; // Latch on unit time outʹÄܵ¥Î»Ê±¼äÊä³öʱÆäËûÖØÒª¼Ä´æÆ÷µÄËø´æ¹¦ÄÜ
// EQep1Regs.QPOSMAX=0xffffffff; //λÖõÄ×î´ó¼ÆËãÖµ
EQep1Regs.QPOSMAX = 7999; //λÖõÄ×î´ó¼ÆËãÖµ
EQep1Regs.QEPCTL.bit.QPEN = 1; // QEP enable ʹÄÜQEP
EQep1Regs.QCAPCTL.bit.UPPS = 5; // 1/32 for unit position¼´Ã¿32¸öQCLK²úÉúÒ»¸öµ¥Î»Î»ÖÃʱ¼þ
EQep1Regs.QCAPCTL.bit.CCPS = 7; // 1/128 for CAP clock ¼´²¶×½¶¨Ê±Æ÷µÄʱÖÓƵÂÊΪSYSCLKOUT/128
EQep1Regs.QCAPCTL.bit.CEN = 1; // QEP Capture Enable ʹÄÜQEP²¶×½¹¦ÄÜ
还请高手多多指教……