Hello,
This is a small code to transmit data from a PIC to another via serial RF link using LINX RF modules.
The transmitter is powered-up only when data needs to be sent (like a simple remote control).
After power up, there is always trash data like "UÔ*u˜" sent by the PIC before a correct message is transmitted. As long as the PIC is powered, all messages will be correct.
I found out, to avoid this trash data, I need to comment the TRISIO statement like in the code hereunder (?!).
But doing so, the command Led = CMCON.6 will stop working and I need a workaround like the IF..THEN commands for the Led.
Any idea what I'm doing wrong?
Code:
' Fuses PIC12F675
@ __CONFIG _CPD_OFF &_BODEN_OFF &_MCLRE_OFF &_PWRTE_OFF &_WDT_OFF &_XT_OSC
' Registers 76543210
OPTION_REG = %10000000 'GPIO Pull-Ups disabled
INTCON = %00000000 'Set Interrupts
ANSEL = %00000010 'Select analog inputs
WPU = %00000000 'Weak pull-ups (check OPTION_REG)
GPIO = %00000000 'Set PORTS
'//TRISIO = %00000010 'Set I/Os
CMCON = %01000100 'Comparator Module settings
VRCON = %10001011 'Voltage reference
' Defines
DEFINE OSC 4
' Variables
D_Out VAR GPIO.0 'Serial Data Out
BattLvl VAR GPIO.1 'Analog Input
Led VAR GPIO.2 'Led is ON if battery level is low
' Program
PAUSE 500 'Delay for VREF to settle
MAIN:
IF CMCON.6 = 1 THEN
HIGH Led
ELSE
LOW Led
ENDIF
'//Led = CMCON.6
SEROUT2 D_Out, 813,["TEST", DEC1 CMCON.6] '1200bps
PAUSE 1000
GOTO MAIN
END
Bookmarks