View Single Post
Old 20-09-2008, 06:16 PM   #8
NGUYEN VU BAO
Nhập môn đệ tử
 
Tham gia ngày: Jun 2005
Bài gửi: 1
:
Dưới đây là cách khởi động QEI.
NHớ TRIS các chân A,B,và index
Giá trị xung nằm trong thanh ghi POSCNT

void setup_encoder(void)
{
ADPCFG = 0xffff; // all digital IO
MAXCNT = 0xffff; // (used as preset when index pulse seen)
POSCNT = 0x0000;
QEICON = 0; // clr CNTERR bit (among others)
QEICONbits.QEIM = 6; // x4 reset by index pulse
QEICONbits.POSRES = 0; // TRICK! dont allow index to reset counter
DFLTCON = 0; // digital filter set off
DFLTCONbits.IMV = 3; // in x4 mode,
DFLTCONbits.QEOUT = 1; // enable digital filter on phase a,b,i
/* set up interrupts for encoder */
IFS2bits.QEIIF = 0; // clear Interrupt flag
IPC10bits.QEIIP = 1; // bits <2:0> are the priority
IEC2bits.QEIIE = 1; // go live
}
NGUYEN VU BAO vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn