RS232 Interface - RS2 |
The asynchronous communication speed and parity can be set with the
setup command. The
hardware lines RTS-CTS and DTR-DSR enable communication between host and
module and are selected by jumpers on the back of the module. Only one pair
can be selected at any one time. (RTS-CTS or DTR-DSR).
If RS485 is available on the module (suffix -K611xxx)
then only RTS-CTS can be used. |
 |
 |
rs232 set up parameters |
setup(RS2)
{
set="96NC";
//quick set up combination "48, 96, 192, 384, 768, 1150 with parity N,
O, E and Command option".
}
setup(RS2)
{ //user must test the application to establish the maximum viable baud rate.
baud=38450;
//num = 110 to 6,250,000. Any value can be set
to allow trimming for deviating clocks i.e. 38450
data=6; //num = 5, 6, 7, 8
stop=15; //num = 1, 15, 2 - note 15 is 1.5 bits
parity=N; //first letter of Odd, Even, None,
Mark, Space
rxi=Y; //set receive
interface as active (Y), a command processing source (C) or disable (N).
Default = N
proc=“;”; //process on receive termination character. See below
procDel=Y; //remove or keep the termination character(s)
before processing
procNum=5; //interrupt on n bytes received
as alternative to proc and procDel.
rxb=8246; //set size of
receive buffer in bytes. Default = 8192 bytes maximum = 256K bytes.
txi=Y;
//set transmit
interface as active (Y), to echo command processing (E) or disable
(N)
txb=8350;
//set size of
transmit buffer in bytes. Default = 8192 bytes
encode=s; //set s=ASCII, w=UNICODE, m=UTF8 or use sr specifying raw text bytes and sd
for raw data.
flow=N;
//none (N), hardware RTS/CTS
or DTR/DSR (H), software XON XOFF (S).
}
Data Processing Interrupt Characters
Termination characters can
be specified to generate an interrupt to process a string of data.
The
proc
parameter is used in the port setup to define the termination characters.
proc = all;
<- trigger on all received characters
proc = CRLF;
<- trigger on a CR followed by LF (0Dh 0A)
proc = CR;
<- trigger on CR (0Dh)
...in command mode rxi=C this is fixed
proc = LF;
<- trigger on LF (0Ah)
proc = NUL;
<- trigger on NUL (00h)
proc = \\xx;
<- trigger on xxh (hex value)
proc = "ABCD";
<- string in format defined by SYSTEM encode param
proc = "\\xx\\xx";
<- string in format defined by SYSTEM encode param
When
sending commands (rxi=C) to the module, processing only occurs when \\0D or 0D
hex is received.
Example: TEXT(MyText,"Hello World");;\\0D
Data Encode Modes
encode=s; 8 bit ASCII data. Codes
00-1F and 80-FF are converted to ASCII "\\00" - "\\1F",
"\\
encode=sr;
8 bit data. Codes 00-07 are processed as cursor
commands. 20-FF are processed as ASCII+ data
encode=sd; 8bit data. All bytes are
processed as raw data.
Other mode styles are available:
D8M - 8 bit data with
U16's, U32's etc output most significant byte first - same as sd
D8L - 8 bit data with
U16's, U32's etc output least significant byte first
D16M
- 16 bit data with bytes processed as most significant byte first -
interrupt occurs after two bytes - same as wd
D16L - 16 bit data with bytes
processed as least significant byte first - interrupt occurs after
two bytes
D32M - 32 bit data with
bytes processed as most significant byte first - interrupt occurs after
four bytes - same as md
D32L - 32 bit data with
bytes processed as least significant byte first - interrupt occurs after
four bytes
Using hex pairs
sh or h8m or h8l = Ascii-Hex Char x 2 = U8; eg "A8" ->
\\A8
h16m = Ascii-Hex Char x 4 = U16 (Most significant hex-pair first) eg "ABCD" ->
\\ABCD
h16l = Ascii-Hex Char x 4 = U16 (Least significant hex-pair first) eg "ABCD"
-> \\CDAB
h32m = Ascii-Hex Char x 8 = U32 (Most significant hex-pair first) eg
"12345678" -> \\12345678
h32l = Ascii-Hex Char x 8 = U32 (Least significant hex-pair first) eg
"12345678" -> \\78563412
Dot Operator
Parameters can be updated using the dot operator
LOAD(RS2.baud,19200);
LOAD(RS2.proc,"CR");
Example usage
setup(RS2)
{
set="96NC"
//quick set up combination "48, 96, 192, 384, 768, 1150 with parity N,
O, E and Command option".
}
PAGE( PageName, PageStyle)
{
POSN(100,100); TEXT ( RecvTxt, "Example", stRecvTxt);; //show received ASCII data on screen
....
....
INT( SerRxInt, RS2RXC, SerRxEvent ); //Used
when rxi=Y
}
FUNC( SerRxEvent )
{
LOAD( Var, RS2 ); // Must read RS2 to clear interrupt
TEXT ( RecvTxt, Var);; //show received ASCII data on screen and refresh.
To update, no style is specified.
}
|
Active v22 except flow
control |
RS232 Interface Test Project
|
This application allows you to test RS232 Interface. You can change various options in the RS232 setup. You can communicate between two modules using the available keyboard and RS232 interface.
|
Designer: ITRON Available for 4.3", 5.7", 7.0" : Download Zip File
|

|
|
|
|
Update Information |
Version |
Title |
Date |
Details |
49.51 |
KEYIO and Serial Port H/W Flow Control Can Stop Transmission |
18 Feb 14 |
|
* Fixed potential problem with transmit being disabled when keyio enabled and hardware flow control disabled. This affected RS232, RS485, ASYNC1, ASYNC2. * The flow control setting is now correctly checked in the KEYIO handler.
|
|
49.51 |
Problem when Port Encode Not Specified |
21 Jan 14 |
|
* A problem was found when the port encode was not being specified, the default should be Ascii Text but was being left undefined. eg SETUP( RS2 ) { ... settings ... encode = s; // If no encode then an error can occur. } * This is now fixed.
|
|
49.44 |
Nesting of priority INT()s |
09 Oct 13 |
|
New functionality has been added to support nesting of priority INT()s, ie a priority interrupt can be interrupted by another priority interrupt with a higher priority (this is now the default behaviour).
A system setup variable has been added to disable this functionality. SETUP(SYSTEM){ intNest = y | n; } // default = y;
For 'y', priority INT()s can be interrupted by higher priority INT()s For 'n', priority INT()s run to completion, then the highest pending priority INT() is processed next.
|
|
49.44 |
Real Time (Priority) Interrupts |
09 Oct 13 |
|
This issue has been resolved. A problem was found with the operating systems' nested interrupt handler. New functionality has been implemented and tested. Nesting of priority INT()s has also been added - see TFT Improvement
|
|
49.39 |
Updating Firmware - ''NAND Error - need physical block'' Error |
13 Jun 13 |
|
When boot code is updated via a serial link (RS2, USB, AS1 etc), the error "NAND Error - need physical block" is reported.
It was found that the boot block range check was invalid when searching for "good" blocks. Fix available in V00.49.39
|
|
49.37 |
Serial Port Buffer Resizing |
10 Jun 13 |
|
* Added the ability to increase size of receive and transmit buffers. > When a buffer size is increased then the old buffer is discarded (memory is not freed) and a new block of memory is allocated for the new buffer. Read and write pointers are reset and all data is flushed. * Decreasing a buffer's size has no effect. * The following ports are affected: RS2, RS4, AS1, AS2, DBG, USB, I2C, SPI
|
|
49.37 |
Modbus - Additional Functionality |
10 Jun 13 |
|
* Added support for function codes 5/6 (write single coil / register). * Added alternative means of accessing register / coil data using 2 dimensional array. 2 dim mode is automatically selected if MB_xxx_REGS / MB_xxx_COILS points to a 2 dim array. In this case the first dimension specified the address and the second holds the data. The coil array must be U16 in 2 dim mode. 2 dim mode is not fully tested.
|
|
49.37 |
Losing Serial Interrupts with ''proc'' |
10 Jun 13 |
|
A new INT() processing scheme has been written which has abandoned a "counter" method and instead checks to see if there are any further "packets" waiting to be processed when the INT() command is run.
The old scheme made use of a counter which was incremented in the "hardware" interrupt handler when a packet was received and then decremented when a LOAD(buf,port); was performed from the INT() function. It had been found that the counter can get out of sync with the packets being received and hence packets are left in the receive buffer when the counter has a value of zero.
The new method, sets a task flag in the "hardware" interrupt handler to say a packet has been received. The INT() function then reads the packet when the LOAD(buf,port); command is used and then checks to see if there is another complete packet in the receive buffer. If there is, then the INT() function is called again, and so on, until there are no more complete packets and then the INT() is exited and normal processing resumes.
|
|
49.37 |
Serial Ports - use with d16l, d16m, d32l, d32m, h16l, h16m, h32l, h32m |
10 Jun 13 |
|
Corrected output for d16l, d16m, d32l, d32m, h16l, h16m, h32l, h32m when source is text variable.
|
|
49.18 |
LOAD from serial port - Files can now be loaded from serial ports using LOAD( NAND, ''RS2/file.ext?size=1234'' );. |
22 Sep 12 |
|
Files can now be loaded from serial ports using LOAD( NAND, "RS2/file.ext?size=1234" ); This allows file data to be read when not operating from command mode, ie can use RUN( "LOAD( NAND, \\22RS2/file.ext?size=1234\\22 );" ); then receive data on RS232 port.
|
|
49.16 |
UART Enable / Disable - Added active=Y/N parameter to RS2/RS4/AS1/AS2/DBG/USB setup. |
14 Sep 12 |
|
Added active=Y/N parameter to RS2/RS4/AS1/AS2/DBG/USB setup. Default is Y for backward compatibility. Allows the associated interface port pins to be disabled by using LOAD(port.active, N);
|
|
49.14 |
RESET( START ); - Added command to restart system without hardware reset and keeping USB/RS232 alive. |
27 Jul 12 |
|
Added command to restart system without hardware reset and keeping USB/RS232 alive. A TUxxxA.MNU file will expected on the SD Card or in NAND. * Note that RESET( LIBRARY ) does the same but doesn't look for a TUxxxA.MNU file as the module expects commands to be sent serially to it in this case.
|
|
19.00 |
RS2 - Added setting of RS232 port with STYLE. |
14 Jul 10 |
|
Added setting of RS232 port with STYLE
|
|
|
|