Ok so now both receiver and transmitter are on portb.2
the picture is up
would the problem be in the software, is the pic16f88 special and need extra attention ?
Last edited by lerameur; - 24th December 2006 at 05:21.
It does...but I think I'm onto something....
On the receiver PIC, it shows:
Waiting...127,22
The 127 is the number of times it's tried to receive data but timed out, the 22 is the number of times it's actually received 4 bytes of data and dropped thru to the display section.
Post your receiver code as it stands again.
Something is amiss. If the serial port wasn't receiving anything (i.e. the serin statement always timed out and went back to loop, the 22 should remain a 0).
for the receiving code, as soon as I open the power supply I get a different number
trial1: Waiting... 111,22
trial2: Waiting... 111,21
trial3: Waiting... 127,22
trial4: Waiting... 107,21
.....
when I leave the power off for a while, it seems to come back to Waiting... 111,22 when the power is turned on
once the number is there , it stays, it do not move, NO increment.
'RECEIVE
INCLUDE "modedefs.bas"
DEFINE OSC 20 'use external 20mhz crystal
CMCON = 7 : ANSEL = 0 : ADCON1 = 7
DEFINE LCD_DREG PORTA ' Set LCD Data port
DEFINE LCD_DBIT 0 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
DEFINE LCD_RSBIT 1 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 0 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
'try1 = count of times waiting for bytes, try2 = count of bytes received
try1 var byte : try2 var byte : temp var word : tempf var word : input portb.3 : pause 2500
loop:
lcdout $fe , $c0 , "Waiting..." , DEC3 try1 , "," , DEC3 try2
try1 = try1 + 1
serin portB.2 , n2400 , 1000 , loop , [ temp.highbyte , temp.lowbyte , tempf.highbyte , tempf.lowbyte ]
try2 = try2 + 2
lcdout $fe , $c0 , "Received.." , DEC3 try1 , "," , DEC3 try2
lcdout $fe , $c0 , "Displaying" , DEC3 try1 , "," , DEC3 try2
lcdout $fe , $80 , "Tc=" , DEC temp , "C,Tf=" , DEC tempf , ".."
lcdout $fe , $c0 , "Displayed." , DEC3 try1 , "," , DEC3 try2
goto loop
End
'TRANSMIT
INCLUDE "modedefs.bas"
DEFINE OSC 20 'use external 20mhz crystal
CMCON = 7 : ANSEL = 0 : ADCON1 = 7
DEFINE LCD_DREG PORTA ' Set LCD Data port
DEFINE LCD_DBIT 0 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
DEFINE LCD_RSBIT 1 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 0 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
try1 var byte : output portb.2 : input portb.3 : dq var portb.4 : temp var word : tempf var word
pause 2500
try2 var byte
loop:
try1 = try1 + 1
lcdout $fe , $c0 , "Getting..." , DEC3 try1 , "," , DEC3 try2
owout DQ , 1 , [ $cc ] : owout DQ , 0 , [ $44 ] : Pause 500
owout DQ , 1 , [ $cc ] : owout DQ , 0 , [ $be ]
owin DQ , 0 , [ temp.LOWBYTE , temp.HIGHBYTE , skip 6 ]
tempf = temp * 9 : tempf = tempf / 5 : tempf = tempf + 32
lcdout $fe , $c0 , "Displaying" , DEC3 try1 , "," , DEC3 try2
lcdout $fe , $80 , "Tc=" , DEC temp , "C,Tf=" , DEC tempf , "F.."
lcdout $fe , $c0 , "Sending..." , DEC3 try1 , "," , DEC3 try2
serout portb.2 , n2400 , [ temp.highbyte , temp.lowbyte ]
serout portb.2 , n2400 , [ tempf.highbyte , tempf.lowbyte ]
lcdout $fe , $c0 , "Data Sent." , DEC3 try1 , "," , DEC3 try2
goto loop
End
Last edited by lerameur; - 24th December 2006 at 05:33.
'RECEIVE
INCLUDE "modedefs.bas"
DEFINE OSC 20 'use external 20mhz crystal
CMCON = 7 : ANSEL = 0 : ADCON1 = 7
DEFINE LCD_DREG PORTA ' Set LCD Data port
DEFINE LCD_DBIT 0 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
DEFINE LCD_RSBIT 1 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 0 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
'try1 = count of times waiting for data, try2 = count of bytes received
try1 var byte : try2 var byte : temp var word : tempf var word : input portb.2 : pause 2500
try1 = 0 : try2 = 0
loop:
lcdout $fe , $c0 , "Waiting.." , DEC3 try1 , "," , DEC3 try2
try1 = try1 + 1
serin portB.2 , n2400 , 1000 , loop , [ temp.highbyte , temp.lowbyte , tempf.highbyte , tempf.lowbyte ]
try2 = try2 + 4
lcdout $fe , $c0 , "Received." , DEC3 try1 , "," , DEC3 try2 : pause 100
lcdout $fe , $c0 , "Display.." , DEC3 try1 , "," , DEC3 try2 : pause 100
lcdout $fe , $80 , "Tc=" , DEC3 temp , "C,Tf=" , DEC3 tempf , ".." : pause 100
lcdout $fe , $c0 , "Shown...." , DEC3 try1 , "," , DEC3 try2 : pause 100
goto loop
End
'TRANSMIT
INCLUDE "modedefs.bas"
DEFINE OSC 20 'use external 20mhz crystal
CMCON = 7 : ANSEL = 0 : ADCON1 = 7
DEFINE LCD_DREG PORTA ' Set LCD Data port
DEFINE LCD_DBIT 0 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
DEFINE LCD_RSBIT 1 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 0 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
try1 var byte : try2 var byte : output portb.2 : input portb.3
dq var portb.4 : temp var word : tempf var word
pause 2500
try1 = 0 : try2 = 0
loop:
try1 = try1 + 1
lcdout $fe , $c0 , "Getting.." , DEC3 try1 , "," , DEC3 try2
owout DQ , 1 , [ $cc ] : owout DQ , 0 , [ $44 ] : Pause 500
owout DQ , 1 , [ $cc ] : owout DQ , 0 , [ $be ]
owin DQ , 0 , [ temp.LOWBYTE , temp.HIGHBYTE , skip 6 ]
tempf = temp * 9 : tempf = tempf / 5 : tempf = tempf + 32
lcdout $fe , $c0 , "Display.." , DEC3 try1 , "," , DEC3 try2
lcdout $fe , $80 , "Tc=" , DEC3 temp , "C,Tf=" , DEC tempf , "F."
lcdout $fe , $c0 , "Sending.." , DEC3 try1 , "," , DEC3 try2
serout portb.2 , n2400 , [ temp.highbyte , temp.lowbyte ]
serout portb.2 , n2400 , [ tempf.highbyte , tempf.lowbyte ]
try2 = try2 + 4 : lcdout $fe , $c0 , "Sent....." , DEC3 try1 , "," , DEC3 try2
goto loop
Try those code chunks. I get the feeling that the lcd at the receiver end might have been overwriting itself, thereby blanking out the data or something. I also added a couple of pauses in there so you could see what was going on. Also, you didn't set the receiver port to an input (I know serin says it does this for you, but I never trust stuff like that).
I tried setting Trisb.2 before and it did ot hnage anythimg so I put it rightback.
Ok now , the sending side, there is an incrementation, and for the first time try2 is incrementing, and it does so by 4.
On the receiver side, first line; empty, second line: 'Waiting... 000,000'
I also added these twoline:
DEFINE LCD_COMMANDUS 2500
DEFINE LCD_DATAUS 250
but no luck either
Last edited by lerameur; - 24th December 2006 at 06:00.
It's not incrementing at all on the receiving side? Try1 should be going up about once a second.
Add:
DEFINE CHAR_PACING 16667
to the transmit program's defines at the beginning. Maybe the receiver is missing characters 'cause they're coming too fast with the software based serin command. If that fixes it, it'll probably work with a value much less than 16667, but it's a start.
Last edited by skimask; - 24th December 2006 at 06:11. Reason: added info
Bookmarks