| Home |
6172 CAN Core Module
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.
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 |
||||||||||||||||||
|
|
|
user memory |
|
||||||||||||||||||
|
|
|||||||||||||||||||||
|
|
|||||||||||||||||||||
|
|
PWMFL PWMFH |
Frequency output configuration (PWM)
|
|
||||||||||||||||||
|
|
PWMDL PWMDH |
Duty cycle output configuration (PWM)
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. |
|
||||||||||||||||||
|
|
MISC |
Miscellaneous command:
|
|
||||||||||||||||||
|
|
I2OUT |
I2C shift-out, write starts shift out after write |
|
||||||||||||||||||
|
|
I2IN |
I2C shift-in, read starts shift-in before read |
|
||||||||||||||||||
|
|
SPISPD |
Shift speed configuration (SPI shifter)
|
|
||||||||||||||||||
|
|
SPIPAT
|
Shift pattern configuration (SPI shifter)
|
|
||||||||||||||||||
|
|
SPIOUT |
Shift-out register, write starts shift out after write |
|
||||||||||||||||||
|
|
SPIIN |
Shift-in register, read starts shift-in before read |
|
||||||||||||||||||
|
|
PORTA |
Parallel output port A, Out1 - Out8 |
|
||||||||||||||||||
|
|
PORTB |
Parallel output port B, Out9 - Out12 |
|
||||||||||||||||||
|
|
PORTC |
Parallel input port C, In1 - In8 |
|
||||||||||||||||||
|
|
AIN1 |
Read 8 bits analogue input 1 |
|
||||||||||||||||||
|
|
AIN2 |
Read 8 bits analogue input 2 |
|
||||||||||||||||||
Reading a write only location returns a zero.
Writing a read only location has no effect.
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 |
|
00C0h - 00FFh |
table of sequences start on read |
|
0100h - 0FFFh |
sequence command memory |
A sequence will start automatically after the selected interval time.
|
Sequence intervals (0021h - 003Fh) |
||
|---|---|---|
|
|
address |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The following table defines the start addresses for each sequence.
|
Sequence start addresses (0040h - 007Fh) |
||
|---|---|---|
|
|
address |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.
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) |
||
|---|---|---|
|
|
address |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) |
||
|---|---|---|
|
|
address |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
Sequencer command memory (0100h - 0FFFh) |
|
|---|---|
|
address |
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
Code |
|
Description |
|
||||||||
|
Working register |
||||||||||||
|
|
|
|
Load working register from user memory |
|
||||||||
|
|
Load working register from PWM frequency low |
|
||||||||||
|
|
Load working register from PWM frequency high |
|
||||||||||
|
|
Load working register from PWM duty cycle low |
|
||||||||||
|
|
Load working register from PWM duty cycle high |
|
||||||||||
|
|
Load working register from I2C bus (shift in a byte) |
|
||||||||||
|
|
Load working register from SPI shift speed configuration |
|
||||||||||
|
|
Load working register from SPI shift pattern configuration |
|
||||||||||
|
|
Load working register from SPI bus (shift in a byte) |
|
||||||||||
|
Shift_Speed (memory location 71) = 0 |
19.6 - 21.1 45.6 - 51.1 148.3 - 166.4 |
|||||||||||
|
|
Load working register from parallel output port A (latch) |
|
||||||||||
|
|
Load working register from parallel output port B (latch) |
|
||||||||||
|
|
Load working register from parallel input port C |
|
||||||||||
|
|
Load working register from 8 bits analogue input 1 |
|
||||||||||
|
|
Load working register from 8 bits analogue input 2 |
|
||||||||||
|
|
|
|
Store working register to user memory |
|
||||||||
|
|
Store working register to PWM frequency low |
|
||||||||||
|
|
Store working register to PWM frequency high |
|
||||||||||
|
|
Store working register to PWM duty cycle low |
|
||||||||||
|
|
Store working register to PWM duty cycle high |
|
||||||||||
|
|
Storing to MISC makes no sense because special sequencer instructions exist to do this (I2STP, I2STA, I2STP, SYNC, CRDY, SRDY) |
|
||||||||||
|
MISC = 0 |
34.3 14.1 16.7 15.2 15.7 |
|||||||||||
|
|
Store working register to I2C bus (shift out a byte) |
|
||||||||||
|
|
Store working register to SPI shift speed configuration |
|
||||||||||
|
|
Store working register to SPI shift pattern configuration |
|
||||||||||
|
|
Store working register to SPI bus (shift out a byte) |
|
||||||||||
|
Shift_Speed (memory location 71 = 0 |
19.6 - 21.1 45.6 - 51.1 148.3 - 166.4 |
|||||||||||
|
|
Store working register to parallel output port A |
|
||||||||||
|
|
Store working register to parallel output port B |
|
||||||||||
|
|
|
|
Load working register with constant (immediate value, 0 - 255) |
|
||||||||
|
|
|
|
Bit wise logical AND working register with constant |
|
||||||||
|
|
|
|
Bit wise logical OR working register with constant |
|
||||||||
|
|
|
|
Bit wise logical XOR working register with constant |
|
||||||||
|
|
|
|
Shift working register n bits left (n = 1 - 7), empty places filled with 0 |
|
||||||||
|
|
|
|
Shift working register n bits right (n = 1 - 7), empty places filled with 0 |
|
||||||||
|
|
|
|
Add constant to working register |
|
||||||||
|
|
|
|
Subtract constant from working register |
|
||||||||
|
|
|
|
Bit wise logical AND working register with memory |
|
||||||||
|
|
|
|
Bit wise logical OR working register with memory |
|
||||||||
|
|
|
|
Bit wise logical XOR working register with memory |
|
||||||||
|
|
|
|
Add memory to working register |
|
||||||||
|
|
|
|
Subtract memory from working register |
|
||||||||
|
Output port A |
||||||||||||
|
|
|
|
Output user memory location to parallel output port A |
|
||||||||
|
|
|
|
Set bit in parallel output port A, bit number 0 - 7 |
|
||||||||
|
|
|
|
Reset bit in parallel output port A |
|
||||||||
|
|
|
|
Toggle bit in parallel output port A |
|
||||||||
|
|
|
|
Set port A masking (the bits allowed to change, NOTE) |
|
||||||||
|
Output port B |
||||||||||||
|
|
|
|
Output user memory location to parallel output port B |
|
||||||||
|
|
|
|
Set bit in parallel output port B |
|
||||||||
|
|
|
|
Reset bit in parallel output port B |
|
||||||||
|
|
|
|
Toggle bit in parallel output port B |
|
||||||||
|
|
|
|
Set port B masking (the bits allowed to change, NOTE) |
|
||||||||
|
Input port C |
||||||||||||
|
|
|
|
Input parallel input port C to user memory location |
|
||||||||
|
|
|
|
Activate a sequence on a port C (0 - 3 = in1 - in4) input edge
|
|
||||||||
|
|
|
|
Activate a sequence on a port C (4 - 7 = in5 - in8) input level
|
|
||||||||
|
|
|
|
Set port C masking (the bits allowed to read, NOTE) |
|
||||||||
|
Serial bus |
||||||||||||
|
|
|
|
Shift-out user memory location via the SPI shifter |
|
||||||||
|
Shift_Speed (memory location 71) = 0 |
16.4 - 17.9 42.4 - 47.9 145.1 - 163.2 |
|||||||||||
|
|
|
|
Shift-in user memory location via the SPI shifter |
|
||||||||
|
Shift_Speed (memory location 71) = 0 |
16.8 - 18.3 42.8 - 48.3 145.5 - 163.6 |
|||||||||||
|
|
|
|
Set SPI shifter shift speed (data is same as memory location 71) |
|
||||||||
|
|
|
|
Set SPI shifter shift pattern (data is same as memory location 72) |
|
||||||||
|
I2C bus |
||||||||||||
|
|
|
|
Shift-out user memory location via the I2C bus |
|
||||||||
|
|
|
|
Shift-in a byte from the I2C bus to the user memory location |
|
||||||||
|
|
|
|
Output a STOP condition on the I2C bus |
|
||||||||
|
|
|
|
Output a START condition on the I2C bus |
|
||||||||
|
|
|
|
Indicates that the next read command will be the last, and should not be acknowledged |
|
||||||||
|
Miscellaneous |
||||||||||||
|
|
|
|
Delay, n times 2 us |
|
||||||||
|
|
|
|
Outputs a 2 uS high pulse on the SYNC output |
|
||||||||
|
|
|
|
Clears READY output (low, out1 .. out12 are tri-stated) |
|
||||||||
|
|
|
|
Sets READY output (high, out1 .. out12 are activated) |
|
||||||||
|
|
|
|
Subroutine call of another sequence (1 .. 31) |
|
||||||||
|
|
|
|
Notify an error to the application layer (like CANopen) |
|
||||||||
|
|
|
|
Notify end of error to the application layer |
|
||||||||
|
|
|
|
End of sequence |
|
||||||||
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.
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).
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.
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 |
|||
|---|---|---|---|
|
|
Code |
|
Description |
|
|
|
|
Shift speed: 1.1 us per bit |
|
|
|
|
Shift pattern |
|
|
|
|
Output port A: reset bit 1, CS of AD7840 low |
|
|
|
|
Shift-out memory byte: 23, (high byte) |
|
|
|
|
Shift-out memory byte: 23, (low byte) |
|
|
|
|
Output port A: set bit 1, CS of AD 7840 high |
|
|
|
|
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