Hi,
try to use the interrupt on pin you use for Software uart, to get attention if byte rx.
I will give you parts of a project of mine, which uses Interrupt Receive on soft serial:
You have to change INT settings! I think you will find out used global variables by yourself, otherwise ask for these...
best, michael
[code:1:15cb25847b]
'-------------------------------------------------------------------------------
' INT0 RX INTERRUPT
'-------------------------------------------------------------------------------
Dim Timeout_rx As Word
Dim Rx_ok As Byte
#if _chip = 168 'Mega168
On Int0 Isr_rx Nosave
Config Int0 = Change
Enable Int0
#endif
#if _chip = 48 ' Mega1280
On Int4 Isr_rx Nosave
Config Int4 = Change
Enable Int4
#endif
Enable Interrupts
' Main here...
do
loop
end
'-------------------------------------------------------------------------------
' RX from WIZ on SoftSerial
'-------------------------------------------------------------------------------
Isr_rx:
#if _chip = 168 ' Mega168
Disable Int0
#endif
#if _chip = 48 ' Mega1280
Disable Int4
#endif
Timeout_rx = 0
Incoming_str = ""
Pos = 1
Do
B = Inkey(#11)
If B > 0 Then
If Pos < 120 Then
Incoming(pos) = B
Incr Pos
End If
Timeout_rx = 0
Else
Incr Timeout_rx
End If
Loop Until Timeout_rx = &H1FFF
'set string end position!
Incoming(pos) = 0
#if Debug_out = 1
Print #1 , Incoming_str
Print #1 , "-"
#endif
Rx_ok = 1
'clear INT0 Int Flag, because int can be flaged in meantime!
#if _chip = 168 ' Mega168
Eifr.intf0 = 1
Enable Int0
#endif
#if _chip = 48 ' Mega1280
Eifr.intf4 = 1
Enable Int4
#endif
Return
[/code:1:15cb25847b]
↧