PDA

View Full Version : Lost in Pic to Pic communication



mesamune80
- 16th May 2006, 09:14
hi,there i am now stuck with pic to pic communication i am using the same crystal for both the microcontroller board i try to send some byte to another pic i use the simulator to monitor the transmit data they look find for me ,but when i program and run it through the hardware i got no response fom another one could some one pls help out? thanks

mat janssen
- 16th May 2006, 09:58
You could post the code. For us is that better to gess.
Otherwise we can say: You forgot to power on the processors.

mesamune80
- 17th May 2006, 12:41
I am using the oshonsoft pic basic pro to write the code my Rx and Tx code are as follows:
(Transmit)
Dim a1 As Byte
Dim temp1 As Byte
EEPROM 21, 4

scan:
If PORTA.2 = 0 Then
Gosub loop
Endif

Goto scan

End

loop:

WaitMs 50
Serin PORTC.1, 9600, temp1 'Rx port 8
Serout PORTC.0, 9600, #temp1
'Write 21, a1
If temp1 <> 0 Then
a1 = temp1
Write 21, a1
Gosub menu
temp1 = 0

Endif

Return

(Receive)

main:
Read 21, a1
Lcdcmdout LcdClear
Lcdcmdout 0xc0
Lcdout #a1

If PORTA.3 = 0 Then
PORTC.2 = 1
Serout PORTC.1, 9600, #a1
a1 = a1 + 1
Write 21, a1
PORTC.2 = 0
Endif
WaitMs 1000
Goto main
end

************************************************** ********
i manage to see the output from the simulator for my Tx routine ,i am sure the data is sending out but the receiver site can't receive it.why?

mat janssen
- 17th May 2006, 14:06
Normaly is a receive done with a serin command and a transmit with a serout command.

mesamune80
- 18th May 2006, 12:41
i already correct the Rx and Tx ,but still cannot ,is it neccessary for me to use HARDWARE USART?

mister_e
- 18th May 2006, 14:24
i'm just affraid about your baudrate definition here



Serin PORTC.1, 9600, temp1 'Rx port 8


9600??? This value is wrong, the calculation is explain in your manual. @9600 bauds, 4MHZ crystal may work or not. Another thing, we don't know your PIC model, it may exist some analog stuff on PORTC... refer to your datasheet for that.

also by seeing.. those lines...


Dim a1 As Byte
.
.
.
WaitMs 50

it sounds to me that you use PROTON instead of Melabs PICBASIC. Sorry dude, you're on the wrong forum. www.picbasic.org/forum

mesamune80
- 19th May 2006, 14:31
I am not using proton ,my basic compiler is from this www.oshonsoft.com
i choose this "PIC Simulator IDE" because it builds in alot of simulator tools,so that i can easily debug my program,its format is quite different if compare to MELAB Pic Basic pro.But it still uses them.

All its keywords can befound here:http://oshonsoft.com/picbasiccompiler.html