Home

Last Modified: 27 January 1999

6172 CAN Core Module


Sequencer versions

Sequencer version 1.0 

The CAN Core module can be configured to process sequences of instructions to interface between the CAN bus and miscellaneous I/O chips (parallel or serial via SPI or I2C), or it can run an application, executing commands from the CAN bus and sending back replies.

A sequence can be started on an action on the CAN bus, an action in the custom I/O or on time intervals.

The sequencer can run up to 32 sequence programs created by the free available Sequencer Assembler.

More information about working with the sequencer can be found in 'How it works' and the Application Notes

The sequence memory consists of 4 Kb flash memory, the user must write the sequence program and configuration into this memory.

64 bytes of RAM memory is available for data exchange, write to a particular memory location can start a preselected sequence, read from a RAM memory location can start a preselected sequence, when the sequence is finished the data will be available for transmission.  


Sequencer data memory

The data memory contains 64 user RAM bytes, the (memory mapped) sequencer I/O and I/O configuration.

The I/O locations (64 - 79) are primarily intended to be able to control all sequencer I/O directly from the CAN bus (without any sequence), for debug and test procedures.
 

Sequencer data memory

Memory address

Symbolic name

Description

Access Type

0


user memory

read / write

up to

63

64 (low byte)

65 (high byte)

PWMFL

PWMFH

Frequency output configuration (PWM)

Data

Description

2 .. 65535

output frequency is (7.5E6 / data) Hz

Output is updated only after writing memory location PWMDH, to prevent change when PWMDx still contains an 'old' value

read / write

66 (low byte)

67 (high byte)

PWMDL

PWMDH

Duty cycle output configuration (PWM)

Data

Description

up to value in PWMDx

output is high for 100 * (PWMDx / PWMFx) percent of the time (always high if this value is equal or higher then PWMDx, always low if this value is zero)

Output is updated only after writing memory location PWMDH.
After writing PWMDH, the user should wait at least a complete PWM cycle (up to 9 milli-seconds if PWMFx is at maximum) before writing a new PWM value.

read / write

68

MISC

Miscellaneous command:

Data

Description

0

outputs a stop condition on the I2C bus

1

outputs a start condition on the I2C bus

2

indicates that the next I2C bus read command is the last before STOP

3

activates the SYNC output for 2 micro-seconds

4

clears the READY output

5

sets the READY output

write only

69

I2OUT

I2C shift-out, write starts shift out after write

write only

70

I2IN

I2C shift-in, read starts shift-in before read

read only

71

SPISPD

Shift speed configuration (SPI shifter)

Data

Description

0

0.3 µS / bit

1

1.1 µS / bit

2

4.3 µS / bit

3

17.1 µS / bit

read / write

72

 

SPIPAT

 

Shift pattern configuration (SPI shifter)

Data

Description

0

1

2

3

4

5

6

7

Input data is shifted in at the center point of the drawn data bits

read / write

73

SPIOUT

Shift-out register, write starts shift out after write

write only

74

SPIIN

Shift-in register, read starts shift-in before read

read only

75

PORTA

Parallel output port A, Out1 - Out8

read / write

76

PORTB

Parallel output port B, Out9 - Out12

read / write

77

PORTC

Parallel input port C, In1 - In8

read only

78

AIN1

Read 8 bits analogue input 1

read only

79

AIN2

Read 8 bits analogue input 2

read only

Reading a write only location returns a zero.
Writing a read only location has no effect.


Sequencer program memory

The 4 Kb flash memory contains the sequencer programs and information about how to start them.

Sequence program memory

Description

0000h - 001Fh

Identification string (defined by user)

0020h

Sequencer version number (10 for version 1.0)

0021h - 003Fh

table of interval times

0040h - 007Fh

table of sequence start addresses

0080h - 00BFh

table of sequences start on write
(start after data memory write)

00C0h - 00FFh

table of sequences start on read
(start before data memory read)

0100h - 0FFFh

sequence command memory

 


Sequence intervals

A sequence will start automatically after the selected interval time.

Sequence intervals (0021h - 003Fh)

Sequence

address

Interval in 10 ms

1

0021h

0, 1 - 255

2

0022h

0, 1 - 255

up to

up to

0, 1 - 255

31

003Fh

0, 1 - 255
no sequence starts when interval = 0
 


Sequence start addresses

The following table defines the start addresses for each sequence.

Sequence start addresses (0040h - 007Fh)

Sequence

address

Start address

0

0040h

0xxxh

1

0042h

0xxxh

up to

up to

0xxxh

31

007Eh

0xxxh
no sequence starts when start address = 0000h

Sequence 0 starts automatically after power up or Node reset, and cannot be started on a interval or reading/writing of user memory or a CALL instruction.
 


Sequence start on write

By writing a memory location by the application, e.g. a CANopen PDO write, a sequence can be started.
The sequence will be started after write to a memory location.

Sequence start on write (0080h - 00BFh)

User memory

address

Sequence

0

0080h

0, 1 - 31

1

0081h

0, 1 - 31

up to

up to

0, 1 - 31

63

00BFh

0, 1 - 31
no sequence starts when sequence = 0
 


Sequence start on read

By reading memory location by the application, e.g. a CANopen PDO write, a sequence can be started.
The sequence will be started before a read from a memory location.

Sequence start on read (00C0h - 00FFh)

User memory

address

Sequence

0

00C0h

0, 1 - 31

1

00C1h

0, 1 - 31

up to

up to

0, 1 - 31

63

00FFh

0, 1 - 31
no sequence starts when sequence = 0

Starting a sequence by reading or writing memory is only valid via CAN bus accesses (e.g. SDO, PDO). Any internal access from within a sequencer program will not start another sequence.
 


Sequence command memory

 

Sequencer command memory (0100h - 0FFFh)

address

command

0100h

first command

0102h

2nd command

up to

more commands

0FFEh

last possible command
A command always contains 2 bytes, the first byte (at even address) is the command, the 2nd byte contains additional data.

When writing the command table to memory, the 4 Kb FLASH memory is in fact completely erased first. So the user must send the complete table.
It is not necessary to send the complete 4 Kb, only the first 100h bytes are mandatory, the rest depends on the total sequencer program length.


Sequencer instructions

Sequencer instructions

Symbolic Name

Code

Data

Description

Execution time in µS (Note)

Working register

LDWM

00h

0 - 63

Load working register from user memory

7.2

64

Load working register from PWM frequency low

7.3

65

Load working register from PWM frequency high

8.9

66

Load working register from PWM duty cycle low

8.9

67

Load working register from PWM duty cycle high

8.5

70

Load working register from I2C bus (shift in a byte)

101.2

71

Load working register from SPI shift speed configuration

11.3

72

Load working register from SPI shift pattern configuration

12

74

Load working register from SPI bus (shift in a byte)

-

Shift_Speed (memory location 71) = 0
Shift_Speed = 1
Shift_Speed = 2
Shift_Speed = 3

13.6 - 14.4
19.6 - 21.1
45.6 - 51.1
148.3 - 166.4

75

Load working register from parallel output port A (latch)

11.1

76

Load working register from parallel output port B (latch)

11.1

77

Load working register from parallel input port C

14.3

78

Load working register from 8 bits analogue input 1

24.8 - 25.6

79

Load working register from 8 bits analogue input 2

24.8 - 25.6

STWM

01h

0 - 63

Store working register to user memory

7.2

64

Store working register to PWM frequency low

7.3

65

Store working register to PWM frequency high

8.9

66

Store working register to PWM duty cycle low

8.9

67

Store working register to PWM duty cycle high

18.1 - 22.5

68

Storing to MISC makes no sense because special sequencer instructions exist to do this (I2STP, I2STA, I2STP, SYNC, CRDY, SRDY)

-

MISC = 0
MISC = 1
MISC = 2
MISC = 3
MISC = 4
MISC = 5

24.1
34.3
14.1
16.7
15.2
15.7

69

Store working register to I2C bus (shift out a byte)

100.4

71

Store working register to SPI shift speed configuration

15.1

72

Store working register to SPI shift pattern configuration

15.6

73

Store working register to SPI bus (shift out a byte)

-

Shift_Speed (memory location 71 = 0
Shift_Speed = 1
Shift_Speed = 2
Shift_Speed = 3

13.6 - 14.4
19.6 - 21.1
45.6 - 51.1
148.3 - 166.4

75

Store working register to parallel output port A

12

76

Store working register to parallel output port B

13.2

LDWC

02h

0 - 255

Load working register with constant (immediate value, 0 - 255)

4.5

ANDWC

03h

0 - 255

Bit wise logical AND working register with constant

4.9

ORWC

04h

0 - 255

Bit wise logical OR working register with constant

4.9

XORWC

05h

0 - 255

Bit wise logical XOR working register with constant

4.9

SHLWC

06h

n

Shift working register n bits left (n = 1 - 7), empty places filled with 0

4.1 + n*0.93

SHRWC

07h

n

Shift working register n bits right (n = 1 - 7), empty places filled with 0

4.1 + n*0.93

ADDWC

08h

0 - 255

Add constant to working register

4.9

SUBWC

09h

0 - 255

Subtract constant from working register

5.1

ANDWM

0Ah

0 - 63

Bit wise logical AND working register with memory

5.7

ORWM

0Bh

0 - 63

Bit wise logical OR working register with memory

5.7

XORWM

0Ch

0 - 63

Bit wise logical XOR working register with memory

5.7

ADDWM

0Dh

0 - 63

Add memory to working register

5.7

SUBWM

0Eh

0 - 63

Subtract memory from working register

5.7

Output port A

OUTA

10h

0 - 63

Output user memory location to parallel output port A

7.5

SETA

11h

0 - 7

Set bit in parallel output port A, bit number 0 - 7

6.1

RESA

12h

0 - 7

Reset bit in parallel output port A

6.3

TGLA

13h

0 - 7

Toggle bit in parallel output port A

6.1

MASKA

14h

0 - 255

Set port A masking (the bits allowed to change, NOTE)

4.5

Output port B

OUTB

20h

0 - 63

Output user memory location to parallel output port B

7.7

SETB

21h

0 - 3

Set bit in parallel output port B

6.1

RESB

22h

0 - 3

Reset bit in parallel output port B

6.3

TGLB

23h

0 - 3

Toggle bit in parallel output port B

6.1

MASKB

24h

0 - 15

Set port B masking (the bits allowed to change, NOTE)

4.5

Input port C

INPC

30h

0 - 63

Input parallel input port C to user memory location

9.5

SEQCE

 

31h

dd

Activate a sequence on a port C (0 - 3 = in1 - in4) input edge

Bit

Description

0 - 1

port bit number (0 - 3)

2

sets rising (1) or falling (0) edge

3 - 7

selects the sequence to start (1 - 31), no sequence when 0

8.9

SEQCL

32h

dd

Activate a sequence on a port C (4 - 7 = in5 - in8) input level

Bit

Description

0 - 1

port bit number (0 - 3 = bit 4 - 7)

2

sets high level (1) or low (0) level

3 - 7

selects the sequence to start (1 - 31), no sequence when 0

6.8

MASKC

34h

0 - 255

Set port C masking (the bits allowed to read, NOTE)

4.5

Serial bus

SHOM

50h

0 - 63

Shift-out user memory location via the SPI shifter

-

Shift_Speed (memory location 71) = 0
Shift_Speed = 1
Shift_Speed = 2
Shift_Speed = 3

10.4 - 11.2
16.4 - 17.9
42.4 - 47.9
145.1 - 163.2

SHIM

51h

0 - 63

Shift-in user memory location via the SPI shifter

-

Shift_Speed (memory location 71) = 0
Shift_Speed = 1
Shift_Speed = 2
Shift_Speed = 3

10.8 - 11.6
16.8 - 18.3
42.8 - 48.3
145.5 - 163.6

SHSPD

52h

0 - 3

Set SPI shifter shift speed (data is same as memory location 71)

9.1

SHPAT

53h

0 - 7

Set SPI shifter shift pattern (data is same as memory location 72)

9.1

I2C bus

I2OM

60h

0 - 63

Shift-out user memory location via the I2C bus

95.7

I2IM

61h

0 - 63

Shift-in a byte from the I2C bus to the user memory location

96.9

I2STP

62h

0

Output a STOP condition on the I2C bus

16.5

I2STA

63h

0

Output a START condition on the I2C bus

26.1

I2LST

64h

0

Indicates that the next read command will be the last, and should not be acknowledged

4.7

Miscellaneous

DELAY

70h

n

Delay, n times 2 us

4.1 + n * 2

SYNC

71h

0

Outputs a 2 uS high pulse on the SYNC output

6.7

CRDY

72h

0

Clears READY output (low, out1 .. out12 are tri-stated)

4.7

SRDY

73h

0

Sets READY output (high, out1 .. out12 are activated)

4.7

CALL

74h

1 - 31

Subroutine call of another sequence (1 .. 31)

11.6

ERROR

75h

1 - 8

Notify an error to the application layer (like CANopen)

5.7

ERROF

76h

1 - 8

Notify end of error to the application layer

5.9

ENDSQ

7Fh

0

End of sequence

4.3

NOTE on execution times:

These are the minimum execution times; the 6172 has three internal interrupt routines (1 mS timer, CAN bus and RS232). These interrupts stay enabled while executing a sequence, so the execution time of a sequence instruction can be longer then stated.


Notes on MASK commands

The MASKx command allows the user to define the port bits used/affected by the sequence.

This is a simple way to prevent a lot of code if a sequence just uses some bits of a output port, while the other bits should be unaffected.

If a bit is one in the MASKx operand, the user can output to and read from this bit. When a operand bit is zero, writing to this bit has no effect on the output ports, reading it always reads zero.

At the beginning of a sequence started on read/write or timer, the masks of all three ports are set to one's. A sequence started with the CALL command does not set the masks (uses the caller's mask).


IMPORTANT NOTE

The 6172 contains a internal watchdog which resets the CAN MCM if it is not serviced within 50 milli-seconds. This watchdog is cleared at the start of a sequence and after the end of it. Be shure that a sequence (including CALLed sequences) does not take more then 50 milli-seconds, or the system will reset.

During the execution of a sequence the CAN bus is not serviced by the main program (received messages are placed in a buffer), so it is bad practice to create a sequence that takes 50 milli-seconds anyway.

If for some reason (like a unintended recursive CALLed sequence) the watchdog does intervene, the restart of the sequencer will keep on resulting in a watchdog reset. In this case it may be impossible to write a new (correct) sequence in memory (because the SDO's aren't serviced).

By holding the IRQ input (connector J4, pin 14) low for 0.5 seconds after the RST input (connector J4, pin 15) is pulsed low and high again, the sequencer will be inhibited until the next (soft- or hardware) reset (with IRQ high). This enables the user to write a new (correct) sequence into memory.
 


Example Sequence

write data into the AD7840 D/A converter.
Shift input is connected to the serial output ,
CS is connected to bit 1 of port A
14 data bits on address 22 and 23
 

Example sequence

Symbolic name

Code

Data

Description

SHSPD

52h

1

Shift speed: 1.1 us per bit

SHPAT

53h

2

Shift pattern

RESA

12h

1

Output port A: reset bit 1, CS of AD7840 low

SHOM

50h

23

Shift-out memory byte: 23, (high byte)

SHOM

50h

22

Shift-out memory byte: 23, (low byte)

SETA

11h

1

Output port A: set bit 1, CS of AD 7840 high

ENDSQ

7Fh

0

End of sequence

 


Generating the sequencer code and tables is made easy using the free available Sequencer Assembler

More information about working with the sequencer can be found in 'How it works' and the Application Notes