Name:
serrxd
Syntax:

SERRXD (qualifier,qualifier...)

SERRXD (qualifier,qualifier...),{#}variable,{#}variable...

SERRXD {#}variable,{#}variable...

Additional optional timeout syntax options for M2, X1 and X2 parts

SERRXD [timeout], (qualifier...)

SERRXD [timeout], (qualifier...),{#}variable,{#}variable

SERRXD [timeout], {#}variable,{#}variable

SERRXD [timeout,address], (qualifier...)

SERRXD [timeout,address], (qualifier...),{#}variable,{#}variable

SERRXD [timeout,address], {#}variable,{#}variable

Qualifiers - are optional variables/constants (0-255) which must be received in exact order before subsequent bytes can be received and stored in variables.

Variable(s) - receive the result(s) (0-255). Optional #'s are for inputting ASCII decimal numbers into variables, rather than raw characters.

Timeout - is an optional variables/constants which sets the timeout period in milliseconds (not available on M parts).

Address - is a label which specifies where to go if a timeout occurs.

Description:

Serial input via the serial input programming pin.

The serrxd command is similar to the serin command, but acts via the serial input pin rather than a general input pin. This allows data to be received from the computer via the programming cable. The PICAXE chip normally constantly scans the serial download pin to see if a computer is trying to initialise a new program download. However when it is desired to use serrxd it is necessary to disable this scanning. This is automatic, and is effectively the same as issuing a disconnect command.

After a serrxd or disconnect command is used it will not be possible to download a new program until:

1) the reconnect command is issued

2) a reset command is issued

3) a hardware reset is carried out.

Remember that is always possible to carry out a new download by carrying out the hard-reset procedure.

 

Reading number values

When the #variable format is used received data will be taken and converted to a number.

All characters received are ignored until the first ASCII digit character is received. A number is then determined until a non-digit character is received. The value stored in the variable will be number represented by the digit characters received. Note that the #variable will not complete until the number has been terminated by a non-digit character being received.


Serial Baud Rate and Input Format

The baud rate at which a serrxd command receives data depends on the operating speed at the time the serrxd command is executed. The default baud rates is 9600 baud for X2 parts operating at the default 8MHz speed and 4800 baud for non-X2 parts when operating at the default 4MHz speed.

All data bytes sent have 8 data bits, use no partity and have 1 stop bit. This is commonly refered to as "8,N,1" format; 9600,N,8,1 for X2 parts at default speeds, 4800,N,8,1 for non-X2 parts at default speed.


Effect of Increased Clock Speed

Increasing the clock speed increases the serial baud rate as shown below (non X2 parts).

4MHz 4800
8MHz 9600
16MHz 19200
32MHz 38400
64MHz 76800
Applies To:
All (except 08, 08M, 18, 18A, 18X, 28, 28A, 28X, 40X)
See Also:
Related Create:
Share:
Print:

Receive serial data from a computer

Receive data into the scratchpad from a computer connected to the programming connector

Code Example:
	disconnect
	serrxd [1000, timeout],@ptrinc,@ptrinc,@ptr
	reconnect
Copy Code Submit an Example

Submit Your Own Code!

You must be logged in to submit code examples. Login now.