Technical Application Notes
Click an item to read from the list below.

Technical Application Notes


 

 

Configuring and Testing the RS-232 Serial Port

Technical Application Note TAN2004001
Revised April 13, 2012

Subject

Technical Application Note (TAN2004001): Configuring and Testing the RS-232 Serial Port

10315

Applicable Product(s)

  • Chameleon
  • Dragonfly2
  • Flea2
  • Flea3
  • Grasshopper
  • Grasshopper2
  • Grasshopper Express
  • Zebra2

Application Note Description

The purpose of this Technical Application Note is to provide the user with a set of basic instructions on how to configure and test the RS-232 serial port functionality for a Point Grey camera. The camera is equipped with a set of general purpose input/output (GPIO) pins that can be accessed via the connector on the back. Different products may use different connectors.

Specific GPIO pins are used for serial port communications. Consult your camera’s Technical Reference for GPIO connector pin layouts, specific wiring information, and GPIO electrical characteristics.

This document also provides a series of examples that illustrate how a user can:

  • Transmit characters to a PC
  • Receive characters from a PC
  • Transmit and receive data simultaneously

Understanding the Serial Buffer System

The camera associates two distinct buffers with the serial port: one for transmitting data and one for receiving data. These two buffers are accessed and controlled via a single set of data access registers. The table below provides a high level description of the registers.

To calculate the base address:

  • Query the offset inquiry register (488h).
  • Multiple the value by 4. (The value is a 32-bit offset.)
  • Remove the 0xF prefix from the result.

Offset

Register Name

Description

488h

SIO_CONTROL_CSR_INQ

32-bit offset register for serial communications control

Base + 000h

SERIAL_MODE_REG

Shared transmit and receive CSRs

Base + 004h

SERIAL_CONTROL_REG
SERIAL_STATUS_REG

Base + 008h

RECEIVE_BUFFER_STATUS_CONTROL

Receive buffer status control

Base + 00Ch

TRANSMIT_BUFFER_STATUS_CONTROL

Transmit buffer status control

Base + 100h

SIO_DATA_REGISTER

Shared access to transmit and receive buffers. Data written to this range is directly reflected in the transmit buffer. Reads from this register range only provide access to data from the receive buffer after the data has been exposed via a write to register 2004h as illustrated in the examples below.

Base + 104h-1FFh

SIO_DATA_REGISTER_ALIAS

Offsets vary by camera model. Always query SIO_CONTROL_CSR_INQ register 488h to obtain the correct offset for your camera.

Transmitting and Receiving Examples

To configure and test these examples:

  • Connect the camera’s serial port to your PC’s serial port. Consult your camera’s Technical Reference for GPIO pin layouts (which pins are designated for RS-232) and GPIO electrical characteristics.
  • Access the camera’s register space. This can be done by using the FlyCap software included in the FlyCapture SDK. Consult your camera’s Technical Reference for register definitions and individual bit descriptions.
  • Access Microsoft’s HyperTerminal program to display the characters received from the camera.

Start-->All Programs-->Accessories-->Communications

Transmit Characters to a PC

This example describes how to send four characters from the camera to the serial port on a PC.


This example uses 0x2000 as the base address. Always query SIO_CONTROL_CSR_INQ register 488h to obtain the correct offset for your camera.

Step

Action

Register

Result

  • Plug the camera in and start FlyCap.

 

 

 

  • Open the Camera Control Dialog and select the Register tab.

Get Register

0x2000

0x060800FF
0x06 = 19200bps
0x08 = 8-bit, no parity, 1 stop
0xFF = 255 byte buffer*

  • Get the current baudrate, character length setting, parity setting, and stop bit setting

 

 

 

  • Open a HyperTerminal window and create a new connection. Set the COM port settings to match the camera settings from step 3.

 

 

 

  • Enable the serial output (transmit).

Set Register

0x2004

0x40000000

  • Verify transmit buffer is ready.

Get Register

0x2004

0x40800000

  • Send four characters to the output buffer on the camera.

Set Register

0x2100

0x31323334
ASCII = 1234

  • Verify that the transmit buffer is storing 4 bytes worth of characters.

Get Register

0x200C

0xFF040000
0xFF = 251 bytes of buffer remaining*
0x04 = 4 bytes currently stored

  • Send the characters from the output buffer to the PC’s serial port.

Set Register

0x200C

0xFF040000
HyperTerminal should echo the characters “1234”

*The actual transmit buffer size may be larger than that reported in step 3 above. When this is the case, the buffer space remaining that is reported in step 8 will not decrease until the actual buffer space remaining is less than 255 bytes.

To send more than four characters either:

  • Repeat steps 7 through 9 above, and send characters in sets of four;

Or,

  • Do a block write of all the characters using registers 0x2104 – 0x21FF. Consult the FlyCapture API documentation for information on block transfers.

Although both types of writes to the transmit buffer may have to be 32-bit aligned, the number of characters transmitted does not. Subsequent writes to the buffer will overwrite characters that were not transmitted during a previous transmit.

Receive Characters from a PC

This example describes how to send four characters from the PC to the camera’s serial port.

This example uses 0x2000 as the base address. Always query SIO_CONTROL_CSR_INQ register 488h to obtain the correct offset for your camera.

Step

Action

Register

Result

  • Repeat steps 1 to 4 above.

 

 

 

  • Enable the serial input (receive).

Set Register

0x2004

0x80000000

  • Verify no receive data framing errors

Get Register

0x2004

0x80000000
0x80040000 indicates an error possibly a noisy RS-232 line or incorrect baudrate/port setting
0x80020000 indicates a receive data parity error

  • Send four characters to the input buffer on the camera. (Type ABCD in the HyperTerminal window.)

 

 

By default, characters are not displayed in the HyperTerminal window. To echo typed characters to the screen, select File-->Properties-->Settings-->ASCII Setup

  • Verify that the receive data buffer is ready to be read.

Get Register

0x2004

0x80200000

  • Verify that the receive buffer is storing 4 bytes worth of characters.

Get Register

0x2008

0x04000000

  • Send four characters from the input buffer to the data access register.

Set Register

0x2008

0x00040000

  • Verify that four characters are ready to be read from the data access register.

Get Register

0x2008

0x00040000

  • Read the four characters from the data access register.

Get Register

0x2100

0x41424344
(Assumes input was ABCD)

To receive more than four characters either:

  • Repeat steps above, and receive characters in sets of four;

Or,

  • Do a block read of all the characters using registers 0x2104 – 0x21FF. Consult the FlyCapture API documentation for information on block transfers.

Although both types of reads from the receive buffer may have to be 32-bit aligned, the number of characters received does not. Extra characters read will be filled with 0s.

The actual receive buffer size may be larger than that reported above.

Transmitting and Receiving Data Simultaneously

Simultaneous transmitting and receiving of data can be achieved in a similar way to the examples above. The primary difference is that register 0x2004 must be set to 0xC0000000 to enable both transmit and receive. Once set, transmit and receive transactions are interleaved as required by the application.