charudatt
- 13th March 2005, 09:05
Hello there,
I have a problem trying to send data to the serial port using PIC 12F629. The code is a very simple test program before I can actually send serial information on the key pressed on the Sony IR remote. I am using direct drive on Pin #2 via 1K resistor to the serial port.
My code is as follows:
@ DEVICE PIC12F629,INTRC_OSC_NOCLKOUT,WDT_ON,PWRT_OFF,BOD_O N,PROTECT_OFF,CPD_OFF,MCLR_OFF
' Define Osc 4 ' We're using a 4 MHz oscillator
TRISIO=0
CMCON=%00000111
Include "Modedefs.Bas"
RELAY VAR GPIO.2 ' Relay output
Ser VAR GPIO.4 ' Serial Out
I VAR BYTE ' TEMP VARIABLE
Welcomemsg:
SEROUT2 SER, 16780,["TEST" , 10] '2400 BAUD RATE
Loop:
TOGGLE RELAY
Pause 500
SEROUT2 ser , 16780 , [I , 10]
I = I +1
IF I = 250 THEN I = 0
goto Loop
end
Although I am getting data out , Its all garbage. Iam looking for 2400 baud rate communication.
regards
Charudatt.
I have a problem trying to send data to the serial port using PIC 12F629. The code is a very simple test program before I can actually send serial information on the key pressed on the Sony IR remote. I am using direct drive on Pin #2 via 1K resistor to the serial port.
My code is as follows:
@ DEVICE PIC12F629,INTRC_OSC_NOCLKOUT,WDT_ON,PWRT_OFF,BOD_O N,PROTECT_OFF,CPD_OFF,MCLR_OFF
' Define Osc 4 ' We're using a 4 MHz oscillator
TRISIO=0
CMCON=%00000111
Include "Modedefs.Bas"
RELAY VAR GPIO.2 ' Relay output
Ser VAR GPIO.4 ' Serial Out
I VAR BYTE ' TEMP VARIABLE
Welcomemsg:
SEROUT2 SER, 16780,["TEST" , 10] '2400 BAUD RATE
Loop:
TOGGLE RELAY
Pause 500
SEROUT2 ser , 16780 , [I , 10]
I = I +1
IF I = 250 THEN I = 0
goto Loop
end
Although I am getting data out , Its all garbage. Iam looking for 2400 baud rate communication.
regards
Charudatt.