3.4.5 Register Injection Tab
Registers may be injected with values set up in a file (see table below). Enter information for register injection here.
For General Purpose Register injection, more than one byte may be injected (for arrays). Therefore, care must be taken to not overwrite data.
Item | Definition |
---|---|
Label | Name the register injection you are specifying (optional). |
Reg/Var | Select a destination register for data
injection from the list*. Listed registers include SFRs (top of list)
and any GPRs used (bottom of list). Note: These GPR variables are shown
only after the program is compiled. |
Trigger | Select when to trigger injection. For most registers, this is either on Demand or when the PC equals a specified value (see next column). If the peripheral is implemented, it can only be triggered on demand. If it is a GPR, it must be triggered on PC. E.g., if SPIBUF is used when SPIBUF is accessed (Read), injection into SPIBUF will occur. For USART/UART registers, injection is Message-based. For more on simulating the USART/UART, see Using a USART/UART. |
PC Value | If Trigger=PC, enter a PC value for
triggering injection. This can be an absolute address or a label in the
code. Note: For MPLAB C18/C30 code, labels are not supported and
therefore local variables may not be in scope when expected. Use
absolute addresses or function names. (Void functions can be defined
if needed. E.g. void PCTrigger(void){
}; ) |
Width | If Trigger=PC, the number of bytes to be injected. |
Data Filename | Browse for the injection (data) file. See below for more information. |
Wrap | Yes – Once all the data from the
file has been injected, start again from the beginning of the file. No – Once all the data from the file has been injected, the last value will continue to be used for injection. |
Format | Select the format of the injection
file. Regular Data File: Hex – ASCII hexadecimal Raw – Raw image, interpreted as binary SCL – SCL format. See spec for definition. Dec – ASCII decimal Message-Based Data File: Pkt – Hex or Raw packet format (used with UART receive register) Note: When importing STI stimulus files the maximum
line length of any line within the old files must not exceed 260
characters. |
Comments | Add descriptive information about the register injection. |
* Not all registers may be displayed. E.g., selecting the ADRESL register on the PIC18F458 for injection will actually inject stimulus into both the ADRESH and ADRESL registers. |
Regular Data File Example
Below is an example of an injection file.
Register Stimulus File in Hex
110
02E
A38
541
1A0
0FD
ADC Buffer Injection Example - dsPIC/PIC24 Devices
A data file with the ADC result values is listed in the example below.
For ADC configured to convert 3 samples, when it completes its first conversion, it puts the result 0x0045 into ADCBUF0. When it completes its second conversion, it puts the result 0x0023 into ADCBUF1. When it completes its third conversion, it puts the result 0x0015 into ADCBUF2.
For the ADC, the BUF0 or ADRESL SFR is used to hook the file into the peripheral. The peripheral simulation will read data from the file when a conversion is complete and place it into the relevant SFR for the result. (This also applies to 10-bit A/Ds where ADRESH and ADRESL need to be populated or adjusted at the conversion completion.)
ADC Register Stimulus File in Hex
0X0045
0X0023
0X0015
0X0000
0X0012
0X0024
0X0049
Message-Based Data File Description
Data in the file will be interpreted in packets as follows:
- HEX-style – spaced, separated hexadecimal numbers will be treated as one packet, e.g., 05 07 6A 6B 105 107. Since the UART is 9-bits wide, receive values larger than 0x1FF will be masked off.
- RAW-style – text between a pair of quotation characters (“) will be treated as one packet, e.g., ”this is a packet“
Two commands will be supported to specify the wait time between two packets:
- wait n unit – where n is a non-negative integer (0 to 264-1) and unit is any time unit (ps, ns, us, ms, sec, min, hr). This command specifies the time period to wait before the next packet will be injected. If unit is invalid, then wait defaults to 0 seconds.
- rand lower upper unit – where lower and upper are non-negative integers (0 to 264-1, lower < upper) and unit is any time unit (ps, ns, us, ms, sec, min, hr). This command specifies a random time period, bounded by lower and upper, to wait before the next packet can be injected. If unit is invalid, then rand defaults to 0 seconds.
If there is a parsing error for either command (e.g., out-of-bound n, lower, or upper, insufficient number of parameters), the command will be treated as wait 0 sec.
A comment line in the data file will begin with two forward slash characters in the first and second character position, e.g. //. An empty line will be ignored.
Adjacent packet lines between wait, rand, and <EOF> will be concatenated as one single packet (without the new line character present at the end-of-line).
Message-Based Data File Examples
Below are examples of message-based injection files.
Register Stimulus File 1
//wait for 0 second, then a packet of ”abc cba“,
//followed by a 9-bit number 0x163
wait 0 sec
61 62 63 20
63 62 61 163
//pause for 20 seconds after the previous packet,
//then a packet ”efgh“
wait 20 sec
”efgh“
//immediately have another packet ”2D4“
wait 0 ms
32 45 34
//pause for 10 ns
wait 10 ns
//pause for 10 more ns, then packet ”43$24!“
wait 10 ns
34 33 24 32 34 21
//pause for a random time from 15 to 20 sec, then a packet
rand 15 20 sec
89 90 91 92 93 94
//pause for a random time from 0 to 100 min, then a packet
rand 0 100 min
11 22 33
Register Stimulus File 2
WAIT 0 SEC
61 62 63 20 6A 62 61
WAIT 200 MS
// THE FOLLOWING IS EQUIVALENT TO ”THE QUICK BROWN FOX“
”THE QUICK BROWN “
”FOX“
// CR-LF IN A PACKET
WAIT 20 SEC
65 66 67 68 13 10
69 70
// 9-BIT VALUE IN A PACKET
WAIT 20 SEC
165 166 167 168
WAIT 30 MS
// THE FOLLOWING IS ”012MIX“
32 33 34
”MIX“
WAIT 100 NS
// THE FOLLOWING BLANK LINE IS IGNORED
64 34 33 24 32 34 21
RAND 15 20 SEC
89 90 91 92 93 94
RAND 0 100 MIN
11 22 33