You are on page 1of 1

#include<18f4331.

h> #FUSES HS,NOWDT,NOPUT,NOLVP,NOPROTECT, NOBROWNOUT #device *=16 adc=10 #use delay(clock=20M) #byte QEICON = 0xB6 #byte DFLTCON=0x60 #byte POSCNTH=0x67 #byte POSCNTL=0x66 #byte MAXCNTH=0x65 #byte MAXCNTL=0x64 void init_qei(){ qeicon=0x08; poscnth=0; poscntl=0; MAXCNTH=0xFF; MAXCNTL=0xFF; } void main(){ setup_timer_5 (T5_INTERNAL | T5_DIV_BY_1); set_timer5(0); set_tris_a(0xFF); set_tris_b(0); set_tris_d(0); init_qei(); while(true){ output_B(poscnth); output_d(poscntl); poscnth=0; poscntl=0; delay_ms(200); } }

You might also like