Stimuli generator for USART simulation
Sometimes you need to simulate a more complex PIC program which processes
the data received through USART interface. To make this task easier,
I have decided to create a small program, which automatically generates
the approppriate asynchronous stimuli for GPSIM.
The program is called usartst (USART stimulus) and is
available there (it is a Perl script, so
the source is already the executable form).
The script accepts the following options:
- "-f 1" This option may be omitted. If present, informs that BRGH
bit will be set.
- "-o filename" This option specifies the output filename.
- "-n stimuli_name" This option specifies the name of the stimulus.
- "-r" This option specifies the divisor value to be written to SPBRG
register
The options should be followed with list of times and strings.
Each position consists of two fields: time when the string should be sent
and the string itself. Time may be expressed as number of cycles from
the start of the simulation, or as the increment from the end of stopbit
of last string (in that case it should be preceded with the "+" sign).
Example:
usartst -f 1 -o stimulus_file -n rs_stim -r 10 3000 String1 +500 "String 2"
Generates the stimulus appropriate for simulating the USART working (eg.) at
115200 bit/s with 20MHz xtal. The first string "String1" will be sent
at 3000th cycle of the simulation, and the second string "String 2" will
be sent 500 cycles after the end of the stopbit of last character of
the first string.
To include such stimulus in your ".stc" file, you can use just
load c stimulus_file
in your command (.stc) file.
I hope, you'll find my sript useful. Any suggestions or improvements are
appreciated. This is the first "draft" version, so the error control
is almost absent.
Wojciech Zabolotny
Last modified: Fri Aug 3 16:47:53 CEST 2001