Hi Experts,
I have a very simple task to perform. I need to pass a couple of bytes from one PIC12F683 to another PIC12F683 and can't get it to work! I've tried everything that I could think of and can't pinpoint the problem. I am using GPIO.5. I have been very successful with SERIN in other projects. In fact, I am receiving packets from a radio receiver using GPIO.0 on this same PIC and it works fine. For some reason GPIO.5 is not cooperating.
The Weak Pullup on GPIO.5 (DataOut) pin is enabled and the data is transmitted and received True". My idle state is in the "Mark" condition (High).
The TX PIC sends this -
Serout DataOut,1,[ProgID,IDByte] ' Xmit Qualifier and new ID
The TX PIC is sending the packet out. I have my oscilloscope connected to verify it. I don't think the Qualifier is being recognized or processed. What am I missing???
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''
Receiver Code -
#CONFIG
; set CONFIG1 for internal oscillator, watchdog on, MCLR pin as OFF
__config _WDTE_ON & _MCLRE_OFF & _INTOSCIO & _PWRTE_ON
#ENDCONFIG
OSCCON = 100000 ' Set system clock 4MHz(1MHz internal w/x4 PLL enabled)
DEFINE OSC 4 ' Calibrate PBP timing to 4MHz system clock
OPTION_REG = 000000 ' Enable Weak Pullups Control
WPU = 100000 ' Disable all Weak Pullups except GPIO.5
ANSEL = 0000 ' No analog inputs
TRISIO = 1001 ' Make GP1, GP2 outputs. GP0, GP3, GP4 & GP5 = inputs
CMCON0 = 0111 ' Turn off comparators
ADCON0 = 0 ' Turn off A/D
IDByte var byte ' Receiver ID.
AlarmByte var Byte ' Received Alarm
AlarmVal var byte ' Alarm Zone(s)
RxIn var GPIO.0 ' Incoming Packet Port
Z1Alarm var GPIO.2 ' Zone1 Alarm LED
Z2Alarm var GPIO.1 ' Zone2 Alarm LED
ByteSum var Byte ' IDByte & AlarmByte Sum Value
ChkSum var byte ' ChkSum value to test
ProgID var byte ' Programmer Present Verify
PrgIn var GPIO.5 ' Programmer Detect & Data Port
IDByteRx var byte ' New IDByte
ProgIDRx var byte ' Received Programmer ID
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''
MainLoop:
Serin PrgIn,1,5000,PassProg,[ProgIDRx],IDByteRx ' Wait for 5 seconds for new I.D. to arrive
if ProgIDRx = $A THEN GOSUB UpdateID ' Verify arrival and execute UpdateID Subroutine
PassProg: ' No Packet received - Timeout reached - Jump out and repeat
PAUSE 500
GOTO MainLoop
UpdateID:
Z1Alarm = 1 : Z2Alarm = 1 ' LEDs to Confirm programing Subroutine
PAUSE 500
Z1Alarm = 0 : Z2Alarm = 0 ' Turn off LEDs
PAUSE 1000
Z1Alarm = 1 : Z2Alarm = 1 ' LEDs to Confirm in programing mode
PAUSE 1000
Z1Alarm = 0 : Z2Alarm = 0 ' Turn off LEDs
IDByte = IDByteRx
Write 1, IDByte ' Write new ID to EEPROM
RETURN
END
I appreciate your help. Thank you!
Bookmarks