17.3.15 Sequencers
When the list record is triggered, a sequence of micro-commands is executed for this record. The micro-commands are called sequences and divided in two types: DCS (a “data collection” or “acquisition” sequence) and MS (“math” sequence). The acquisition and math sequences are executed in the order shown in Figure 17-8.
The sequences commands should be programmed (initialized) by software in the register’s arrays. One array (16 of SDATACMDx command registers) is dedicated for the acquisition sequences, and another array (16 of SMATHCMDx command registers) contains the math sequences. These arrays can be split to store several sequences. For the acquisition commands, it is defined by SPLITx[1:0] bits in the SDATAMAP register, and for the math commands, it is defined by SPLITx[1:0] bits in SMATHMAP register. The SPLITx[1:0] bits allow dividing all commands in the arrays into a few sequences as shown in Table 17-2.
Sequencies | Command registers and control SPLIT bits in SnDATAMAP and SnMATHMAP registers | |||
---|---|---|---|---|
0-3 | 4-7 | 8-11 | 12-15 | |
SPLIT0[1:0] | SPLIT1[1:0] | SPLIT2[1:0] | SPLIT3[1:0] | |
One 16 steps sequence (registers: 0-15) | 0 | 0 | 0 | 0 |
Two 8 steps sequences (registers: 0-7 and 8-15) | 2 | 2 | 2 | 2 |
One 8 step and two 4 steps sequences (registers: 0-7, 8-11 and 12-15) | 2 | 2 | 3 | 3 |
Four 4 steps sequences (registers: 0-3, 4-7, 8-11 and 12-15) | 3 | 3 | 3 | 3 |
When the acquisition commands array is split into a few sequences, the commands in each sequence should be assigned to a sequence number set in the DATASEQ[2:0] bits of the ITCLSxSEQ register. The user can select any unique sequence number from four to seven to identify the sequence. The acquisition sequence number settings example is shown in The Acquisition Sequence Number Assignments.
The Acquisition Sequence Number Assignments
// Split all commands in 3 sequences
SDATAMAPbits.SPLIT0 = 2;
SDATAMAPbits.SPLIT1 = 2;
SDATAMAPbits.SPLIT2 = 3;
SDATAMAPbits.SPLIT3 = 3;
// List 0 will be processed by sequence number 5
ITCLS0SEQbits.DATASEQ = 5;
// Assign first 8 steps sequence to number 5 to be processed by list 0
SDATAMAPbits.DATASEQ0 = 5;
SDATAMAPbits.DATASEQ1 = 5;
// List 1 will be processed by sequence number 6
ITCLS1SEQbits.DATASEQ = 6;
// Assign second 4 steps sequence to number 6 to be processed by list 1
SDATAMAPbits.DATASEQ2 = 6;
// List 2 will be processed by sequence number 7
ITCLS2SEQbits.DATASEQ = 7;
// Assign third 4 steps sequence to number 7 to be processed by list 2
SDATAMAPbits.DATASEQ3 = 7;
When the math commands array is split into a few sequences, the commands in each sequence should be assigned to a sequence number set in the MATHSEQ[2:0] bits of the ITCLSxSEQ register. The user can select any unique sequence number from four to seven to identify the sequence.
One acquisition (data collection) sequence can execute two different math sequences. The second math sequence must be defined by a SECOND bit in the SMATHCMDx command and SECONDx bits in the SMATHMAP register.
The math map register contains comparison CMPx bits which must be always set for the sequences comparing the result with thresholds when CM[2:0] bits in the ITCLSxCON register are not zero (comparison is enabled).
The math map register has an accumulation ACCx bits which must be always set for the sequences executed several times per record (accumulating result) when ACCCNT[3:0] bits are not zero.
The math sequence number settings example is shown in Math Sequence Number Assignments. In this example the acquisition commands are configured to execute math sequence number 5, which is an eight-step sequence, twice. If the SECOND bit is set in SMATHCMDx register, then only the sequence with SECONDx bits set in SMATHMAP register will be executed.
Math Sequence Number Assignments
// Split all commands in 2 sequences
SMATHMAPbits.SPLIT0 = 2;
SMATHMAPbits.SPLIT1 = 2;
SMATHMAPbits.SPLIT2 = 2;
SMATHMAPbits.SPLIT3 = 2;
// List 0 will be processed by two math sequences number 5
ITCLS0SEQbits.MATHSEQ = 5;
// List 0 will accumulate result. Each sequence will be executed 4 times per record
ITCLS0SEQbits.ACCEN = 1;
ITCLS0SEQbits.ACCCNT = 2;
// First 8 steps sequence called when SECOND0 bit = 0 in SMATHCMDx register
// The sequence will be executed several times per record (accumulation mode)
SMATHMAPbits.MATHSEQ0 = 5;
SMATHMAPbits.MATHSEQ1 = 5;
SMATHMAPbits.SECOND0 = 0;
SMATHMAPbits.SECOND1 = 0;
SMATHMAPbits.ACC0 = 1;
SMATHMAPbits.ACC1 = 1;
// Second 8 steps sequence called when SECOND bit = 1 in SMATHCMDx register
// The sequence will be executed several times per record (accumulation mode)
SMATHMAPbits.DATASEQ2 = 5;
SMATHMAPbits.DATASEQ3 = 5;
SMATHMAPbits.SECOND2 = 1;
SMATHMAPbits.SECOND3 = 1;
SMATHMAPbits.ACC2 = 1;
SMATHMAPbits.ACC3 = 1;