CPM2A_PROGRAMMING MANUAL (W353-E1-2) (986750), страница 82
Текст из файла (страница 82)
Since interrupt inputs are recorded, masked interrupts will be serviced as soon as the mask is removed unless they are cleared first.Set the corresponding bit in C2 to 1 to clear an I/O interrupt input. Bits 00 to 03correspond to 00003 to 00006. Bits 04 to 15 should be set to 0.Word C2 bits: 3 2 1 0Interrupt input 00003 (0: Do not clear, 1: clear)Interrupt input 00004 (0: Do not clear, 1: clear)Interrupt input 00005 (0: Do not clear, 1: clear)Interrupt input 00006 (0: Do not clear, 1: clear)473Section 7-29Interrupt Control InstructionsRead Current Mask Status(C1=002)This function reads the current mask status for interrupt inputs 00003 to 00006and writes that information to word C2.
The corresponding bit will be ON if theinput is masked. (Bits 00 to 03 correspond to 00003 to 00006.)Word C2 bits: 3 2 1 0Interrupt input 00003 (0: not masked, 1: masked)Interrupt input 00004 (0: not masked, 1: masked)Interrupt input 00005 (0: not masked, 1: masked)Interrupt input 00006 (0: not masked, 1: masked)Restart Counter andUnmask Interrupt(C1=003 or C1=004)These functions are used to restart interrupt inputs (counter mode) by refreshingthe counter SV (in SR 240 to SR 243) and unmasking the interrupt input (00003to 00006).Set C1=3 to restart decrementing counters or C1=4 (CPM2A/CPM2C PCs only)to restart incrementing counters.Set the corresponding bit in C2 to 0 to refresh the input’s counter SV and unmaskthe interrupt. (Bits 00 to 03 correspond to 00003 to 00006.)Word C2 bits: 3 2 1 0Interrupt input 00003 counterInterrupt input 00004 counterInterrupt input 00005 counterInterrupt input 00006 counterUse the differentiated variation (@INT(89)) or an input condition that is ON forjust one cycle when executing INT(89) with C1=003 or C1=004.
The counter PVwill be reset to the SV if INT(89) is executed while the counter is operating, so theinterrupt will never be generated if INT(89) is executed every cycle.When INT(89) is executed with C1=003 or C1=004 and the SV word contains anon-zero SV (0001 to FFFF), the corresponding counter will begin operating(decrementing or incrementing) and the corresponding interrupt will be enabledin counter mode.
When the count reaches the SV, an interrupt will be generatedand the PV will be returned to the SV, so interrupts will be generated repeatedlyuntil the counter is stopped.Writing 0000 to a counter’s SV word (SR 240 to SR 243) and executing INT(89)to refresh the SV will stop the counter and disable the corresponding interrupt.To restart the counter, write the non-zero SV to its SV word and execute INT(89).(The SV words are reset to 0000 at the start of operation, so the counter’s SVmust be written to its SV word from the ladder program.)When an interrupt has already been enabled (unmasked), the SV cannot be refreshed just by writing a new value to the SV word. Refresh the SV by executingINT(89) with C1=003 (C1=004 for an incrementing counter).A counter mode interrupt can be masked by executing INT(89) with C1=000 andthe corresponding bit in C2 set to 1, but an input will operate in interrupt inputmode, not counter mode, when its corresponding bit in C2 is set to 0.Masking or Unmasking AllInterrupts(C1=100 or C1=200)474All interrupts, including input interrupts, interval timer interrupts, and high-speedcounter interrupts, can be masked or unmasked as a group by executingINT(89) with C1=100 or C1=200.
The masked inputs are recorded, but ignored.The global mask is in addition to any masks on the individual types of interrupts.Furthermore, clearing the masks for all interrupts does not clear the masks onthe individual types of interrupts, but restores them to the masked conditions thatexisted before INT(89) was executed to mask them as a group.Do not use INT(89) to mask interrupts unless it is necessary to temporarily maskall interrupts. Always use INT(89) instructions in pairs to do so, using the firstINT(89) instruction to mask all interrupts and the second one to unmask all interrupts.Section 7-29Interrupt Control InstructionsINT(89) cannot be used to mask and unmask all interrupts from within interruptroutines.Masking Interrupts (C1=100)Use the INT(89) instruction with C1=100 to mask all interrupts.(@)INT(89)100000000If an interrupt is generated while interrupts are masked, interrupt processing willnot be executed but the interrupt will be recorded for the input, interval timer, andhigh-speed counter interrupts.
The interrupts will then be serviced as soon asinterrupts are unmasked.Unmasking Interrupts (C1=200)Use the INT(89) instruction with C1=200 to unmask interrupts as follows:(@)INT(89)200000000FlagsER:A data area boundary is exceeded.Indirectly addressed DM word is non-existent. (Content of *DM word isnot BCD, or the DM area boundary has been exceeded.)C1 is not 000 to 004,100, or 200.C2 is not 0000 to 000F.INT(89) is executed with C1=100 or C1=200 while an interrupt programwas being executed.INT(89) is executed with C1=100 when all inputs were already masked.C1=200 when inputs were not all unmasked.7-29-2 INTERVAL TIMER – STIM(69)Ladder SymbolsOperand Data AreasC1: Control data #1STIM(69)@STIM(69)C1C1C2C2C3C3000 to 008, 010 to 012C2: Control data #2IR, SR, AR, DM, HR, TC, LR, #C3: Control data #3IR, SR, AR, DM, HR, TC, LR, #Note STIM(69) is an expansion instruction in the CPM2A/CPM2C and SRM1(-V2).The function code 69 is the default setting and can be changed if desired.LimitationsC1 must be 000, 003, 006.
or 010.If C1 is 000 or 003, C3 represents a BCD subroutine number up to 0049.If C1 is 006, constants cannot be used for C2 or C3.If C1 is 010, both C2 and C3 must be set to 000.475Section 7-29Interrupt Control InstructionsDescriptionSTIM(69) is used to control the interval timers by performing four basic functions: starting the timer for a one-shot interrupt, starting the timer for scheduledinterrupts, reading the timer’s PV, and stopping the timer. Set the value of C1 tospecify which of these functions will be performed, as shown in the followingtable.
Refer to Section 2 Special Features for more detailed descriptions of usinginterval timer interrupts. STIM(69) is also described in more detail after the table.C1 valueStarting Interrupt Timers(C1= 000 or 003)Function000Starts the one-shot interrupt timer.003Starts the scheduled interrupt timer.006Reads the timer PV.010Stops the timer.Set C1=000 to activate the one-shot interrupt timer. Set C1=003 to start thescheduled interrupt timer.C2, which specifies the timer’s SV, can be a constant or the first of two wordscontaining the SV. The settings are slightly different depending on the methodused.C2 = ConstantIf C2 is a constant, it specifies the SV of the decrementing counter in BCD. Thesetting range is 0000 to 9999 (0 to 9.999 ms). (The timing units are fixed at 1 ms.)C3 specifies subroutine number: 0000 to 0049.C2 = Word AddressIf C2 is a word address, the content of C2 contains the SV of the decrementingcounter (BCD, 0000 to 9999).The content of C2+1 specifies the timing units (BCD, 0005 to 0320) in units of0.1 ms.
The decrementing time interval can thus be 0.5 to 32 ms.The timer SV is: (the content of C2) × (the content of C2+1) × 0.1 ms.C3 specifies subroutine number: 0000 to 0049.Reading the Timer PV(C1=006)Set C1=006 to read the timer PV.C2 specifies the first of two destination words that will receive the timer’s PV. C2receives the number of times the decrementing counter has been decremented(hexadecimal, 0000 to 9999) and C2+1 receives the timing units (BCD in 0.1 msunits).C3 specifies the destination word that receives the time which has elapsed sincethe last time the timer was decremented (BCD in 0.1 ms units).Note The time that has elapsed since the timer was started is computed as follows:((Content of C2) × (Content of C2+1)) + ((Content of C3)) × 0.1 msStopping the Timer(C=010)Set C1=010 to stop the timer. C2 and C3 have no function and should both be setto 000.FlagsER:C1 is not 000, 003, 006, or 010.A specified subroutine number is not between 0000 and 0049.Indirectly addressed DM word is non-existent.
(Content of *DM word isnot BCD, or the DM area boundary has been exceeded.)A data area boundary has been exceeded.476Section 7-30Communications Instructions7-30 Communications Instructions7-30-1 RECEIVE – RXD(47)Operand Data AreasLadder SymbolsD: First destination wordRXD(47)@RXD(47)DDCCNNIR, SR, AR, DM, HR, TC, LRC: Control word#N: Number of bytesIR, SR, AR, DM, HR, TC, LR, #LimitationsThis instruction is available in the CPM2A/CPM2C and SRM1(-V2) only.D and D+(N÷2)–1 must be in the same data area.DM 6144 to DM 6655 cannot be used for D or N.N must be BCD from #0000 to #0256.
(#0000 to #0061 in Host Link mode)DescriptionWhen the execution condition is OFF, RXD(47) is not executed. When theexecution condition is ON, RXD(47) reads N bytes of data received at the portspecified in the control word, and then writes that data in words D to D+(N÷2)–1.Up to 256 bytes of data can be read at one time.If fewer than N bytes are received, the amount received will be read.Note Refer to 4-1Communications Functions for details on using the RXD(47) instruction, setting communications protocol in the PC Setup, etc.! CautionControl WordThe PC will be incapable of receiving more data once 256 bytes have been received if received data is not read using RXD(47).
Read data as soon as possible after the Reception Completed Flag is turned ON (AR 0806 for theRS-232C port, AR 0814 for the peripheral port.)The value of the control word determines the port from which data will be readand the order in which data will be written to memory.Digit number:3 2 1 0Byte order0: Most significant bytes first, same word1: Least significant bytes first, same wordNot used. (Set to 00.)Port0: RS-232C port.1: Peripheral port.477Section 7-30Communications InstructionsThe order in which data is written to memory depends on the value of digit 0 of C.Eight bytes of data 12345678... will be written in the following manner:Digit 0 = 0MSBD1D+13D+25D+37FlagsER:LSB2468Digit 0 = 1MSBD2D+14D+26D+38Digit 0 = 2MSB LSBD1D+123D+245D+367Digit 0 = 3MSBD1D+12D+24D+36LSB1357LSB357The settings in C are not correct.N is greater than 256.The PC Setup is not set for no-protocol mode.RXD(47) is already being executed.AR 08: AR 0806 will be turned ON when data has been received normally at theRS-232C port.