CH Tech EM405D User Manual

Page 27

Advertising
background image

21

Example 4:

Read 32 words starting at address 0x0 followed by 32 words starting at address 0x80


starting address = 0x0

block size = 32

number of blocks = 2

address increment = 128



4.3.4.1

Block Write command


The Block Write command writes a block of data to an M-module. A maximum of 1024 bytes
can be written in a single command. The number of bytes written in any given command is
equal to:

number of bytes = number of blocks * block size * word size


The block write command consists of nine command bytes and any number (up to 1024) of data
bytes. The return value is a single status byte indicating the success of the command.

Command Syntax:

0x40 md as ws ad ai nh nl bs d1 d0


Return:

SC


where

md = module (0 = invalid, 1 = M-module A, 2 = M-module B)

as = address space (0 = I/O, 1 = future use)

ws = word size (2 = 16-bit word, other values for future use)

ad = starting address (0 to FF)

ai = address increment (number to increment address by after each write)

nh = number of blocks to read (upper 4 bits)

nl = number of blocks to read (lower 8 bits)

bs = block size in words (i.e., number of words per block)

d1 = data (MSB)

d0 = data (LSB)

… = the number of data bytes = ws

bs

nb

SC = Status Code


Example (values shown hex):

To write the data values 0x1234, 0x5678, 0x9ABC to M-module A starting at I/O Register 4, send the
following command:


Command:

cd md as ws ad ai

nh nl

bs dh1 dl1 dh2 dl2 dh3 dl3

Send:

40 01 00 02 04 02 00 03 01 12 34 56 78 9A BC


Receive:

00 (if successful)


Advertising