Code:
@ __config & _WDT_ON & _PWRTE_OFF & _BODEN_ON & _LVP_OFF & _CP_OFF & _DATA_CP_OFF
'@ Device pic16F877, HS_OSC, BOD_ON, PWRT_OFF, WDT_ON, PROTECT_OFF
Define osc 20
DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
DEFINE HSER_SPBRG 64 ' 19200 Baud @ 20MHz, 0.16%
DEFINE HSER_CLROERR 1 ' Clear overflow automatically
ADCON1 = 7
old_val VAR BYTE
new_val VAR BYTE
direction_bit VAR BIT
enc_counter VAR WORD
enc_counter = 10000
new_val = PORTB & %00000011
TRISB = %00000011
INCLUDE "DT_INTS-14.bas" ' Base Interrupt System
INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler RBC_INT, _LED, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
@ INT_ENABLE INT_INT ; enable external (INT) interrupts
rs232:
pause 1
goto rs232
LED:
old_val = new_val
new_val = PORTB & %00000011
IF new_val = old_val Then again
direction_bit = old_val.bit0 ^ new_val.bit1
IF direction_bit = 1 Then
enc_counter = enc_counter + 1
else
enc_counter = enc_counter - 1
endif
hserout [dec enc_counter]
again:
@ INT_RETURN
PBP 2.47 , 250 or 250C in all version same errors ???
can you edit and post my code full please sir?
Bookmarks