Ricardo
- 28th April 2008, 04:35
IŽm trying to send data from PIC to BS2 via serout2 but the values are sistematically been altered.
The 12F675 is generating the sequence:
0,1,2,3,4,...,255
And the BS2 is receiving:
128,129,130,131, ... , 157,158,159,128, 129,130,...
I verified and OSCCAL was not erased.
Things got better when i include the line:
Define OSCCAL_1K 1
on the code, but the problem did not dissapear at all.
here are the codes:
12F675 code:
include "bs2defs.bas"
Define OSCCAL_1K 1 ' Set OSCCAL for 1K Device
ANSEL=%00000000
CMCON=%00000111
Trisio = %11111111 ' Set all ports as inputs
Trisio.4 = 0 ' Set port GP4 as output
saida CON 4
i var byte
pause 1000
loop:
for i = 0 to 255
serout2 saida,16780,[i]
pause 100
next
pause 2000
goto loop
end
The BS2 code:
' {$STAMP BS2}
' {$PBASIC 2.5}
entr PIN 1
entr_mode CON 16780 'entrada baudmode = 2400/8N1 INV
PAUSE 10
p VAR Byte
Start:
SERIN entr,entr_mode,[p]
DEBUG DEC p," "
GOTO Inicio
Seems to me that is some timing problem. I overnight on this problem without a solution. I must be missing something trivial, but I cant figure out what!
IŽll appreciate any help
The 12F675 is generating the sequence:
0,1,2,3,4,...,255
And the BS2 is receiving:
128,129,130,131, ... , 157,158,159,128, 129,130,...
I verified and OSCCAL was not erased.
Things got better when i include the line:
Define OSCCAL_1K 1
on the code, but the problem did not dissapear at all.
here are the codes:
12F675 code:
include "bs2defs.bas"
Define OSCCAL_1K 1 ' Set OSCCAL for 1K Device
ANSEL=%00000000
CMCON=%00000111
Trisio = %11111111 ' Set all ports as inputs
Trisio.4 = 0 ' Set port GP4 as output
saida CON 4
i var byte
pause 1000
loop:
for i = 0 to 255
serout2 saida,16780,[i]
pause 100
next
pause 2000
goto loop
end
The BS2 code:
' {$STAMP BS2}
' {$PBASIC 2.5}
entr PIN 1
entr_mode CON 16780 'entrada baudmode = 2400/8N1 INV
PAUSE 10
p VAR Byte
Start:
SERIN entr,entr_mode,[p]
DEBUG DEC p," "
GOTO Inicio
Seems to me that is some timing problem. I overnight on this problem without a solution. I must be missing something trivial, but I cant figure out what!
IŽll appreciate any help