السلام عليكم
اخوانى
اريد تحويل الكود التالى الى هكس الكود مكتوب بالبيك بيسك برو
الرجاء تغيير المتحكم والكريستالة الى
المتحكم :18F4550
الكريستالة :4 او 8
وهذا هو الكود:
كود:
'--------------------------------------------------
* DEVICE PIC16F819, INTRC_OSC_NOCLKOUT, WDT_OFF, LVP_OFF, PWRT_ON, PROTECT_OFF, BOD_OFF
INCLUDE "MODEDEFS.BAS"
TRISA = %00011111
TRISB = %00000001
DEFINE OSC 8
OSCCON = $70
IR_DETECT VAR PORTB.0
COM VAR PORTB.1
LED VAR PORTB.2
COM_BAUD CON N2400
IR_PULSE VAR WORD(33)
ACTIVE_LOW CON 0
ACTIVE_HIGH CON 1
RESULT VAR WORD
I VAR BYTE
POWER VAR WORD
LOW LED
'------- WAIT FOR START OF PACKET TRANSMISSION -------
START:
PULSIN IR_DETECT,ACTIVE_HIGH,IR_PULSE(0)
IF IR_PULSE(0) = 0 THEN START
'-------------- INPUT PULSE STREAM -------------------
FOR I = 1 TO 33
PULSIN IR_DETECT,ACTIVE_HIGH,IR_PULSE(I)
NEXT I
'--------------- CALL SUBROUTINES --------------------
GOSUB PULSE_TIMING
GOSUB DISPLAY_PULSE
GOSUB CONVERT_BITS
GOTO START
'--------------- DISPLAY PULSE STREAM ----------------
DISPLAY_PULSE:
HIGH LED
FOR I = 0 TO 33
IF IR_PULSE(I) > 150 THEN
SEROUT COM,COM_BAUD,["1"]
ELSE
SEROUT COM,COM_BAUD,["0"]
ENDIF
NEXT I
SEROUT COM,COM_BAUD,[13,10]
LOW LED
RETURN
'-------- CONVERT USEABLE BITS DECIMAL VALUE ---------
CONVERT_BITS:
HIGH LED
RESULT = 0
POWER = 1
FOR I = 0 TO 8
IF IR_PULSE(15 + I) > 150 THEN
RESULT = RESULT + POWER
ENDIF
POWER = POWER * 2
NEXT I
SEROUT COM,COM_BAUD,["BITS 15 TO 23 = ",#RESULT," DECIMAL",13,10,13,10]
LOW LED
RETURN
'------------ DISPLAY PULSE TIMING VALUES -------------
PULSE_TIMING:
HIGH LED
FOR I = 0 TO 33
IF IR_PULSE(I) > 150 THEN
SEROUT COM,COM_BAUD,["PULSE ", #I, " - ", #(IR_PULSE(I) * 53) / 10, " US = 1"]
ELSE
SEROUT COM,COM_BAUD,["PULSE ", #I, " - ", #(IR_PULSE(I) * 53) / 10, " US = 0"]
ENDIF
SEROUT COM,COM_BAUD,[13,10]
NEXT I
LOW LED
RETURN
تحياتى