Syntax:
SerReceive channel, output
Command Availability:
Available on all microcontrollers.
Explanation:
This command will read a byte from the RS232 channel given by
channel according to the rules set using InitSer, and store the
received byte in the variable output.
Example:
'This program will read a byte from PORTB.2, and set the LED on if
'the byte is more than 50. This can be used with the SerSend
'example program.
#chip 16F88, 8
#define RecAHigh PORTB.2 ON
#define RecALow PORTB.2 OFF
#define LED PORTB.0
Dir PORTB.0 Out
Dir PORTB.2 In
InitSer 1, r9600, 1 + WaitForStart, 8, 1, none, normal
Do
SerReceive 1, Temp ' <<< the SerReceive instruction
If Temp <= 50 Then Set LED Off
If Temp > 50 Then Set LED On
LoopKey line: SerReceive 1, Temp — blocks until a byte arrives on software-UART channel 1, then stores it in Temp, using the bit rate, start/stop bits and parity previously configured by InitSer on that same channel.
See Also:
- RS232 Software Overview — category overview
- InitSer — configures the channel before SerReceive can be used
- SerSend — the counterpart command for sending a byte

