Charles Templeman
New Member
Help, Can not get Second SERIN call to function. SERIN (or Hserin ) will hang when called a second time.
SEROUT works correctly. Appreciate any suggestions.
Here is my code:
'PROCESSOR TYPE -- 16F877A
Define CLOCK_FREQUENCY = 16
Define CONFIG = 0x3f3a
AllDigital
ConfigPin RC6 = Output 'serial OUTPUT
ConfigPin RC7 = Input 'serial INPUT
Dim k(10) AsByte 'INPUT BUFFER
Dim i AsByte 'FOR/NEXT COUNTER
Define LCD_BITS = 4 '- defines the number of data interface lines (allowed values are 4 and 8; default is 4)
Define LCD_DREG = PORTC '- defines the port where data lines are connected to (default is PORTB)
Define LCD_DBIT = 0 '- defines the position of data lines for 4-bit interface (0 or 4; default is 4), else ignore
Define LCD_EREG = PORTD '- defines the port where E line is connected to (default is PORTB)
Define LCD_EBIT = 3 '- defines the pin where E line is connected to (default is 2)
Define LCD_RSREG = PORTD '- defines the port where RS line is connected to (default is PORTB)
Define LCD_RSBIT = 2 '- defines the pin where RS line is connected to (default is 3)
Define LCD_COMMANDUS = 5000 '- defines the delay after LCDCMDOUT statement (default value is 5000)
Define LCD_DATAUS = 100 '- defines the delay after LCDOUT statement (default value is 100)
Define LCD_INITMS = 100 '- defines the delay for LCDINIT statement (default value is 100
Lcdinit 0 'no cusor
startup:
Call read_comm(k(10)) 'read 10 items from comm port 'WORKS once AFTER PIC POWER ON
For i = 1 To 10
Serout PORTC.6, 9600, " = ", k(i), CrLf 'send 10 items -- THESE CORRECTLY DISPLAY ON PC
Lcdcmdout LcdClear
Lcdout "LAST IN CHAR " k(i)
Next i
WaitMs 1000
Call read_comm(k(10)) 'read 10 items from comm port 'SECOND CALL FAILS with LOCK UP
For i = 1 To 10
Serout PORTC.6, 9600, " = ", k(i), CrLf 'send 10 items
Lcdcmdout LcdClear
Lcdout "RCVD CHAR IS " k(i)
Next i
End 'read 10 items from comm port
'****************************************
Proc read_comm(j AsByte)
For i = 1 To 10
Serin PORTC.7, 9600, j 'read in 1 item
k(i) = j
Next i
End Proc
SEROUT works correctly. Appreciate any suggestions.
Here is my code:
'PROCESSOR TYPE -- 16F877A
Define CLOCK_FREQUENCY = 16
Define CONFIG = 0x3f3a
AllDigital
ConfigPin RC6 = Output 'serial OUTPUT
ConfigPin RC7 = Input 'serial INPUT
Dim k(10) AsByte 'INPUT BUFFER
Dim i AsByte 'FOR/NEXT COUNTER
Define LCD_BITS = 4 '- defines the number of data interface lines (allowed values are 4 and 8; default is 4)
Define LCD_DREG = PORTC '- defines the port where data lines are connected to (default is PORTB)
Define LCD_DBIT = 0 '- defines the position of data lines for 4-bit interface (0 or 4; default is 4), else ignore
Define LCD_EREG = PORTD '- defines the port where E line is connected to (default is PORTB)
Define LCD_EBIT = 3 '- defines the pin where E line is connected to (default is 2)
Define LCD_RSREG = PORTD '- defines the port where RS line is connected to (default is PORTB)
Define LCD_RSBIT = 2 '- defines the pin where RS line is connected to (default is 3)
Define LCD_COMMANDUS = 5000 '- defines the delay after LCDCMDOUT statement (default value is 5000)
Define LCD_DATAUS = 100 '- defines the delay after LCDOUT statement (default value is 100)
Define LCD_INITMS = 100 '- defines the delay for LCDINIT statement (default value is 100
Lcdinit 0 'no cusor
startup:
Call read_comm(k(10)) 'read 10 items from comm port 'WORKS once AFTER PIC POWER ON
For i = 1 To 10
Serout PORTC.6, 9600, " = ", k(i), CrLf 'send 10 items -- THESE CORRECTLY DISPLAY ON PC
Lcdcmdout LcdClear
Lcdout "LAST IN CHAR " k(i)
Next i
WaitMs 1000
Call read_comm(k(10)) 'read 10 items from comm port 'SECOND CALL FAILS with LOCK UP
For i = 1 To 10
Serout PORTC.6, 9600, " = ", k(i), CrLf 'send 10 items
Lcdcmdout LcdClear
Lcdout "RCVD CHAR IS " k(i)
Next i
End 'read 10 items from comm port
'****************************************
Proc read_comm(j AsByte)
For i = 1 To 10
Serin PORTC.7, 9600, j 'read in 1 item
k(i) = j
Next i
End Proc