Serial comunication between 2 PIC12f675 (Pic Basic language)

Status
Not open for further replies.

lanpu

Newbie level 1
Joined
Oct 24, 2010
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,288
Hi, can somebody help me please!!!

I have 2 pic12f675 and this code for a serial cominication:

Recceiver
Code:
DEVICE pic12F675,intrc_osc_noclkout, wdt_off, pwrt_on, mclr_off, bod_off, protect_off
INCLUDE "modedefs.bas"

define OSCCAL_1K 1


ledr var gpio.1
leda var gpio.2
ledv var gpio.4
datos var byte

high ledr
pause 500
low ledr

recibir:

serin gpio.0,N2400,1,recibir,datos
if datos="A" then high ledr
pause 1000
if datos="B" then high leda
pause 1000
if datos="C" then high ledv
pause 1000

low ledr:low leda:low ledv
goto recibir
end

Emitter:

Code:
  DEVICE pic12F675, intrc_osc_noclkout, wdt_off, pwrt_on, mclr_off, bod_off, protect_off
INCLUDE "modedefs.bas"
define OSC 4 
define OSCCAL_1K 1

botonA var gpio.1
botonB var gpio.2
botonC var gpio.4

transmitir:
if botonA=0 then envio1
if botonB=0 then envio2
if botonC=0 then envio3
goto transmitir

envio1:
serout gpio.5,N2400,["A"]
pause 500
goto transmitir

envio2:
serout gpio.5,N2400,["B"]
pause 500
goto transmitir

envio3:
serout gpio.5,N2400,["C"]
pause 500
goto transmitir

end

i dont know what's wrong, somebody knows the way to do this comunication???


some example or something??

thanks!
 

If it's still relevant, I think you better try and move this question to the "Microcontrollers" forum. I'm not sure "PC Programming" is the right place.
 

try this


receiver:

Code:
DEVICE pic12F675,intrc_osc_noclkout, wdt_off, pwrt_on, mclr_off, bod_off, protect_off
INCLUDE "modedefs.bas"

define OSCCAL_1K 1


ledr var gpio.1
leda var gpio.2
ledv var gpio.4
datos var byte

high ledr
pause 500
low ledr

recibir:

serin gpio.0,N2400,1,recibir,datos
if datos=1 then high ledr
pause 1000
if datos=2 then high leda
pause 1000
if datos=3 then high ledv
pause 1000

low ledr:low leda:low ledv
goto recibir
end


transmitter:



Code:
DEVICE pic12F675, intrc_osc_noclkout, wdt_off, pwrt_on, mclr_off, bod_off, protect_off
INCLUDE "modedefs.bas"
define OSC 4 
define OSCCAL_1K 1

botonA var gpio.1
botonB var gpio.2
botonC var gpio.4

dim data as byte

transmitir:
if botonA=0 then envio1
if botonB=0 then envio2
if botonC=0 then envio3
goto transmitir

envio1:
data = 1
serout gpio.5,N2400,[data]
pause 500
goto transmitir

envio2:
data = 2
serout gpio.5,N2400,[data]
pause 500
goto transmitir

envio3:
data = 3
serout gpio.5,N2400,[data]
pause 500
goto transmitir

end
 

Does this code work has anyone tried it? Im working on a similiar program
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…