Prices
| Support | Download
AVR
Simulator IDE is powerful application that supplies AVR developers with
user-friendly graphical development environment for Windows with integrated
simulator (emulator), Basic compiler, assembler, disassembler and debugger.
AVR Simulator IDE currently supports the following microcontrollers from
the Atmel megaAVR and tinyAVR product lines and mature 90S family: AT90S2313,
AT90S2323, AT90S2343, AT90S4433, AT90S8515, AT90S8535, ATmega8, ATmega16,
ATmega32, ATmega48, ATmega64, ATmega88, ATmega128, ATmega162, ATmega168,
ATmega8515, ATmega8535, ATtiny11, ATtiny12, ATtiny13, ATtiny24, ATtiny25,
ATtiny26, ATtiny44, ATtiny45, ATtiny84, ATtiny85, ATtiny2313. Additional
AVR models sharing the same architecture will be supported in the new releases.
You
are welcome to download the fully functional evaluation copy of the software
on the downloads
page. PIC Simulator IDE requires a license to operate after the evaluation
period. If you would like to see several original comments I received from
the users of my Simulators, please visit the comments
page
There
are four types of licenses available:
Personal
license for individuals grants right to one single user to use the
program on one home personal computer for non-commercial purposes.
Commercial/educational
license for business companies, educational institutions and individuals
using the software for commercial purposes grants right to the owner to
use the program on one single computer. Multiple licenses are required
for multiple computers with program installations.
Site
license grants right to the institution to use the program on all computers
located on one institution site (the most suitable choice for computer
labs).
Institution
license grants right to the institution to use the program on all computers
on all sites that belong to the institution.
Once
purchased license will be valid for all future versions of the corresponding
application.
Your
personal license is a permanent license that will enable you to use the
software on your personal computer even when you get the new machine in
the future. It is by no means linked to your present computer, but only
to your name.
AVR
Simulator IDE main features:
-
Main simulation interface showing internal microcontroller architecture,
-
FLASH program memory editor, EEPROM data memory editor, stack SRAM space
viewer,
-
Microcontroller pinout interface for simulation of digital I/O and analog
inputs,
-
Variable simulation rate, simulation statistics,
-
Breakpoints manager for code debugging with breakpoints support,
-
AVR assembler, AVR disassembler,
-
Powerful AVR Basic compiler with smart Basic source editor,
-
AVR Basic compiler features: three basic data types (1-bit, 1-byte, 2-byte),
optional 4-byte (32-bit) data type with 32-bit arithmetics, arrays, all
standard AVR Basic language elements, optional support for structured language
(procedures and functions), high level language support for using internal
EEPROM memory, using internal A/D converter module, using interrupts, serial
communication using internal hardware UART, software UART implementation,
I2C communication with external I2C devices, Serial Peripheral Interface
(SPI) communication, interfacing character LCDs, interfacing graphical
LCDs with 128x64 dot matrix, R/C servos, stepper motor control, 1-Wire
devices, DS18S20 ...
-
PC's serial port terminal for communication with real devices connected
to serial port,
-
LCD module simulation interface for character LCD modules,
-
Graphical LCD module simulation interface for 128x64 graphical LCD modules,
-
Stepper motor phase simulation interface for stepper motor driving visualization,
-
Simulation module for external I2C EEPROMs from 24C family,
-
Hardware UART simulation interface,
-
Software UART simulation interface for software implemented UART routines,
-
Oscilloscope (with Zoom feature) and signal generator simulation tools,
-
7-segment LED displays simulation interface,
-
Support for external simulation modules,
-
Extensive program options, color themes, ...
Site
License users reference list:
Educational/Commercial
users reference list:
-
WWR Development Inc., Columbia, United States
AVR
Simulator IDE Getting Started Page
This
presentation will help you to test the included DEMO.BAS example and in
that way get acquainted with the most frequently used features of AVR Simulator
IDE.
EXAMPLE
1
- Examine demo.bas
file from the application folder. This program first writes 32 bytes of
data to an external 24C256 I2C EEPROM and then verifies the operation by
reading the data back. During these operations formatted text is displayed
on the attached 2x16 character LCD module. File demo.asm was generated
using integrated Basic compiler. File demo.hex was generated using integrated
assembler.
Define
LCD_BITS = 8
Define
LCD_DREG = PORTB
Define
LCD_DBIT = 0
Define
LCD_RSREG = PORTD
Define
LCD_RSBIT = 1
Define
LCD_EREG = PORTD
Define
LCD_EBIT = 3
Define
LCD_RWREG = PORTD
Define
LCD_RWBIT = 2
Define
LCD_COMMANDUS = 1000 'delay after LCDCMDOUT,
default value is 5000
Define
LCD_DATAUS = 50 'delay after LCDOUT, default
value is 100
Define
LCD_INITMS = 2 'delay used by LCDINIT, default
value is 100
'the last
three Define directives set the values suitable for simulation; they should
be omitted for a real device
Dim addr
As Word
Dim data
As Byte
Symbol
sda = PORTC.1
Symbol
scl = PORTC.0
Lcdinit
LcdCurBlink
WaitMs
1 'suitable for simulation
For addr
= 0 To 31
Lcdcmdout LcdClear
data = 200 - addr
I2CWrite sda, scl, 0xa0, addr, data
Lcdout "Write To EEPROM"
Lcdcmdout LcdLine2Home
Lcdout "(", #addr, ") = ", #data
WaitMs 1 'suitable for simulation
Next addr
For addr
= 0 To 31
Lcdcmdout LcdClear
I2CRead sda, scl, 0xa0, addr, data
Lcdout "Read From EEPROM"
Lcdcmdout LcdLine2Home
Lcdout "(", #addr, ") = ", #data
WaitMs 1 'suitable for simulation
Next addr
- Start AVR Simulator
IDE.
- Click on Options\Select
Microcontroller.
- Select 'ATmega32'
and click on Select button.
- Click on Options\Change
Clock Frequency.
- Enter '4'
and click on OK button.
- Click on Options\List
I/O Registers First. The list on General Purpose Working and I/O Registers
panel will be inverted.
- Click on Tools\BASIC
Compiler
- Click on File\Open
- Select demo.bas
file and click on Open. The basic source program will be displayed in the
editor.
- Click on Tools\Compile
& Assemble & Load. The compiler will generate demo.asm file with
assembler source. The integrated assembler will assemble that file and
make demo.lst and demo.hex files. Demo.hex file will be loaded into the
simulator program memory.
- Click on Tools\LCD
Module. That will open the LCD Module simulator window. Click on Yes to
load the LCD parameters from the basic program file.
- Click on Setup
button on the LCD Module Window.
- Click on Change
LCD Module Color Scheme.
- Enter '3'
for blue background choice and confirm with OK.
- Click on Apply!
button. Reposition the windows on the screen to get better view.
- Click on Tools\I2C
EEPROM. Another simulation interface will be displayed.
- Click on SDA
Line label and select PORTC.1 pin.
- With similar
procedure select PORTC.0 pin for the SCL Line.
- Reposition
the windows on the screen to get better view. If needed use Always On Top
option on the windows.
- Select the
Rate\Extremely Fast simulation rate.
- Click on Options\Infinite
Loop Stops Simulation.
- Click on Simulation\Start.
The simulation will start immediately.
- Watch the
simulation on the main simulation interface, LCD and I2C EEPROM simulation
modules. Around 10ms of real simulation time will be necessary to pass
to see the first activity on the LCD module. Watch Real Time Duration field.
- The simulation
can be stopped any time by clicking on Simulation\Stop. Otherwise, it will
be automatically stopped after the whole program has been simulated and
infinite loop detected.
- Try to run
the simulation in Step By Step mode. Then use Run To Next Basic Statement
command.
Screenshot
AVR
Basic Compiler Reference Manual
The
list of all Basic compiler keywords:
1WIRE_REG,
1WIRE_BIT,
1WIREINIT,
1WIRESENDBIT,
1WIREGETBIT,
1WIRESENDBYTE,
1WIREGETBYTE,
ADCIN,
ADC_CLOCK,
ADC_SAMPLEUS,
ALLOW_ALL_BAUDRATES,
ALLOW_MULTIPLE_HSEROPEN,
AND,
AS,
ASM,
BIT,
BREAK,
BYTE,
CALL,
CASE,
CLOCK_FREQUENCY,
CONST,
CRLF,
DEFINE,
DIM,
DISABLE,
DS18S20START,
DS18S20READT,
ELSE,
ENABLE,
END,
END
FUNCTION,
END
PROC,
ENDIF,
ENDSELECT,
EXIT,
FALSE,
FOR,
FREQOUT,
FUNCTION,
GLCD_DREG,
GLCD_RSREG,
GLCD_RSBIT,
GLCD_EREG,
GLCD_EBIT,
GLCD_RWREG,
GLCD_RWBIT,
GLCD_CS1REG,
GLCD_CS1BIT,
GLCD_CS2REG,
GLCD_CS2BIT,
GLCDINIT,
GLCDCLEAR,
GLCDPSET,
GLCDPRESET,
GLCDCLEAN,
GLCDPOSITION,
GLCDWRITE,
GLCDOUT,
GLCDIN,
GLCDCMDOUT,
GOSUB,
GOTO,
HALT,
HIGH,
HSERGET,
HSERIN,
HSEROUT,
HSEROPEN,
I2CWRITE,
I2CREAD,
I2CREAD_DELAYUS,
I2CCLOCK_STRETCH,
I2CWRITE1,
I2CREAD1,
I2CPREPARE,
I2CSTART,
I2CSTOP,
I2CSEND,
I2CRECA,
I2CRECEIVEACK,
I2CRECN,
I2CRECEIVENACK,
IF,
LCD_BITS,
LCD_DREG,
LCD_DBIT,
LCD_RSREG,
LCD_RSBIT,
LCD_EREG,
LCD_EBIT,
LCD_RWREG,
LCD_RWBIT,
LCD_COMMANDUS,
LCD_DATAUS,
LCD_INITMS,
LCD_READ_BUSY_FLAG,
LCD_LINES,
LCD_CHARS,
LCDINIT,
LCDOUT,
LCDCMDOUT,
LCDCLEAR,
LCDHOME,
LCDDISPLAYON,
LCDDISPLAYOFF,
LCDCUROFF,
LCDCURBLINK,
LCDCURUNDERLINE,
LCDCURBLINKUNDERLINE,
LCDLEFT,
LCDRIGHT,
LCDSHIFTLEFT,
LCDSHIFTRIGHT,
LCDLINE1HOME,
LCDLINE2HOME,
LCDLINE3HOME,
LCDLINE4HOME,
LCDLINE1CLEAR,
LCDLINE2CLEAR,
LCDLINE3CLEAR,
LCDLINE4CLEAR,
LCDLINE1POS,
LCDLINE2POS,
LCDLINE3POS,
LCDLINE4POS,
LCDDEFCHAR,
LF,
LONG,
LOOKUP,
LOW,
MOD,
NAND,
NEXT,
NOR,
NOT,
NXOR,
ON
INTERRUPT,
OR,
POINTER,
PROC,
READ,
RESERVE,
RESUME,
RETURN,
SELECT
CASE,
SERIN,
SERININV,
SEROUT,
SEROUTINV,
SEROUT_DELAYUS,
SERVOIN,
SERVOOUT,
SHIFTLEFT,
SHIFTRIGHT,
SIMULATION_WAITMS_VALUE,
SPI_CS_REG,
SPI_CS_BIT,
SPI_SCK_REG,
SPI_SCK_BIT,
SPI_SDI_REG,
SPI_SDI_BIT,
SPI_SDO_REG,
SPI_SDO_BIT,
SPICS_INVERT,
SPICLOCK_INVERT,
SPICLOCK_STRETCH,
SPICSON,
SPICSOFF,
SPIPREPARE,
SPISEND,
SPISENDBITS,
SPIRECEIVE,
SQR,
STARTFROMZERO,
STEP,
STEP_A_REG,
STEP_A_BIT,
STEP_B_REG,
STEP_B_BIT,
STEP_C_REG,
STEP_C_BIT,
STEP_D_REG,
STEP_D_BIT,
STEP_MODE,
STEPHOLD,
STEPCW,
STEPCCW,
SYMBOL,
THEN,
TO,
TOGGLE,
TRUE,
WAITMS,
WAITUS,
WEND,
WHILE,
WORD,
WRITE,
XOR.
Standard
Basic language elements
Default
extension for basic source files is BAS. The compiler output is assembler
source file (with ASM extension) that can be translated to binary code
using integrated assembler. Smart editor marks all reserved keywords in
different color, that simplifies debugging process. BASIC compiler's assembler
output has all necessary comment lines, that makes it very useful for educational
purposes, also.
Four
data types are supported:
- Bit (1-bit,
0 or 1)
- Byte (1-byte
integers in the range 0 to 255)
- Word (2-byte
integers in the range 0 to 65,535)
- Long (4-byte
integers in the range 0 to 4,294,967,295) - optional module
Declarations
may be placed anywhere in the program. All variables are considered global.
The total number of variables is limited by the available microcontroller
SRAM memory. Variables are declared using DIM statement:
DIM A
AS BIT
DIM B
AS BYTE
DIM C
AS WORD
DIM D
AS LONG
If
necessary, variable address can be specified during declaration:
DIM B
AS BYTE @ 0x062
It
is also possible to use one-dimensional arrays. For example:
DIM A(10)
AS BYTE
declares an
array of 10 Byte variables with array index in the range [0-9].
RESERVE
statement allows advanced usage by reserving some of the SRAM locations
to be used by in-code assembler routines. For example:
RESERVE
0x065
High
and low byte of a word variable can be addressed by .HB and .LB extensions.
Individual bits can be addressed by .0, .1, ..., .14 and .15 extensions.
It is possible to make conversions between Byte and Word data types using
.LB and .HB extensions or directly:
DIM A
AS BYTE
DIM B
AS WORD
A = B.HB
A = B.LB
'This statement is equivalent to A = B
B.HB =
A
B.LB =
A
B = A
'This statement will also clear the high byte of B variable
High
word (composed by bytes 3 and 2) and low word (composed by bytes 1 and
0) of a long variable can be addressed by .HW and .LW extensions. Byte
0 can be addressed by .LB and byte 1 by .HB extensions. For example:
DIM A
AS BYTE
DIM B
AS WORD
DIM C
AS LONG
A = C.LB
B = C.HW
All
general purpose working and I/O registers are available as Byte variables
in basic programs. Individual bits of a Byte variable can be addressed
by .0, .1, .2, .3, .4, .5, .6 and .7 extensions or using official names
of the bits. The lists of these predefined variables and official bit names
for the selected AVR device can be viewed by selecting Show System Variables
and Show System Bit Names commands from the Options menu of the basic compiler
window.
DIM A
AS BIT
DIM B
AS BYTE
A = B.7
B.6 =
1
R26 =
10
XH = R26
DDRD.1
= 1
DDRB =
255
PORTD.1
= 1
PORTB
= 255
GIMSK.PCIE
= 1
SREG.SREG_I
= 1
Standard
short forms for accessing port registers and individual chip pins are also
available (PA, PB, PC, ... can be used as Byte variables; PA0, PA1, PA2,
..., PB7, PC0, ... are available as Bit variables):
PB = 0xFF
PD5 =
1
Any
variable that is declared as a Byte or Word variable using Dim statement
can be used as a pointer to internal data SRAM memory when it is used as
an argument of POINTER function. The value contained in the variable that
is used as a pointer should be in the appropriate range. Here is one example:
DIM A
AS WORD
DIM B
AS BYTE
DIM C
AS LONG
A = 0x070
B = POINTER(A)
'The content of SRAM location $070 will be loaded to variable B
B = B
+ 0x55
A = A
- 1
POINTER(A)
= B 'Modified B value will be stored to SRAM location $06F
A = 0x077
C = 0x12345678
POINTER(A)
= C 'Four SRAM locations $077-$07A will be loaded with the 4-byte value
contained in variable C
It
is also possible to use symbolic names (symbols) in programs:
SYMBOL
LED1 = PORTB.0
LED1 =
1
SYMBOL
ADC_START = ADCSRA.ADSC
ADC_START
= 1
Constants
can be used in decimal number system with no special marks, in hexadecimal
number system with leading 0x or leading $ notation (or with H at the end)
and in binary system with leading % mark (or with B at the end). Keywords
True and False are also available for Bit type constants. For example:
DIM A
AS BIT
DIM B
AS BYTE
A = TRUE
B = 0x55
B = %01010101
Constants
can also be assigned to symbolic names using CONST directive:
DIM A
AS WORD
CONST
PI = 314
A = PI
There
are three statements that are used for bit manipulation - HIGH, LOW and
TOGGLE. If the argument of these statements is a bit in one of the PORT
registers, then the same bit in the corresponding DDR register is automatically
set, configuring the affected pin as an output pin. Some examples:
HIGH PORTB.0
LOW ADCSRA.ADEN
TOGGLE
PB1
Five
arithmetic operations (+, -, *, /, MOD) are available for Byte, Word and
Long data types. The compiler is able to compile all possible complex arithmetic
expressions. For example:
DIM A
AS WORD
DIM B
AS WORD
DIM C
AS WORD
A = 123
B = A
* 234
C = 2
C = (B
* C - 12345) / (A + C)
Square
root of a number (0-65535 range) can be calculated using SQR function:
DIM A
AS WORD
A = 3600
A = SQR(A)
For
Bit data type variables seven logical operations are available. It is possible
to make only one logical operation in one single statement. Logical operations
are also available for Byte and Word variables. For example:
DIM A
AS BIT
DIM B
AS BIT
DIM C
AS BIT
C = NOT
A
C = A
AND B
C = A
OR B
C = A
XOR B
C = A
NAND B
C = A
NOR B
C = A
NXOR B
DIM A AS
WORD
DIM B
AS WORD
A = A
OR B
PORTB
= PORTD AND %11110000
The
clock frequency of the target device can be specified by setting the CLOCK_FREQUENCY
parameter with the DEFINE directive (the value is expressed in MHz). This
parameter should be setup at the beginning of the basic program. For example:
DEFINE
CLOCK_FREQUENCY = 20
The
GOTO statement uses line label name as argument. Line labels must be followed
by colon mark ":". Here is one example:
DIM A
AS WORD
A = 0
loop:
A = A + 1
GOTO loop
WAITMS
and WAITUS statements can be used to force program to wait for the specified
number of milliseconds or microseconds. It is also possible to use variable
argument of Byte or Word data type. These routines use Clock Frequency
parameter that can be changed from the Options menu. WAITUS routine has
minimal delay and step that also depend on the Clock Frequency parameter.
DIM A
AS WORD
A = 100
WAITMS
A
WAITUS
50
PLEASE
NOTE: When writing programs for real AVR devices you will most likely use
delay intervals that are comparable to 1 second or 1000 milliseconds. Many
examples in this help file also use such 'real-time' intervals. But, if
you want to simulate those programs you have to be very patient to see
something to happen, even on very powerful PCs available today. For simulation
of 'WaitMs 1000' statement on 4MHz you have to wait the simulator to simulate
4000000 instructions and it will take considerable amount of time even
if 'extremely fast' simulation rate is selected. So, just for the purpose
of simulation you should recompile your programs with adjusted delay intervals,
that should not exceed 1-10ms. But, be sure to recompile your program with
original delays before you download it to a real device. There is an easy
way to change arguments of all WAITMS statements in a large basic program
with a value in the range 1-10 for simulation purposes. With one line of
code setting parameter SIMULATION_WAITMS_VALUE with DEFINE directive, the
arguments of all WAITMS statements in the program will be ignored and the
specified value will be used instead during compiling. Setting the value
0 (default) for this parameter (or omitting the whole line) will cancel
its effect and the compiled code will be ready again for the real hardware.
FREQOUT
statement can be used to generate a train of pulses (sound tone) on the
specified pin with constant frequency and specified duration. It has three
arguments. The first argument is the pin that the tone will be generated
on. It should previously be setup as an output pin. The second argument
specify the tone frequency and it must be a constant in the range 1-10000Hz.
The third argument defines the tone duration and it also must be a numeric
constant in the range 1-10000ms. Choosing higher tone frequencies with
low microcontroller clock frequency used may result in somewhat inaccurate
frequency of the generated tones. FREQOUT statement can be alternatively
used in 'variable mode' with Word data type variables instead of constants
for the last two arguments. In this mode of usage the second argument is
supposed to hold the half-period of the tone (in microseconds) and the
third argument must hold the total number of pulses that will be generated.
The following code will generate one second long tone on PB0 pin with 600Hz
frequency:
DDRB.0
= 1
FREQOUT
PORTB.0, 600, 1000
Four
standard BASIC structures are supported: FOR-TO-STEP-NEXT, WHILE-WEND,
IF-THEN-ELSE-ENDIF and SELECT CASE-CASE-ENDSELECT. Here are several examples:
DIM A
AS BYTE
DDRB =
255
A = 255
WHILE
A > 0
PORTB = A
A = A - 1
WAITMS 100
WEND
PORTB
= A
DDRB.0
= 1
loop:
IF PINA.0
THEN
PORTB.0 = 1
ELSE
PORTB.0 = 0
ENDIF
GOTO loop
DIM A AS
WORD
DDRB =
255
FOR A
= 0 TO 10000 STEP 10
PORTB = A.LB
NEXT A
DIM A AS
BYTE
DIM B
AS BYTE
DIM C
AS BYTE
B = 255
C = 2
DDRB =
255
FOR A
= B TO 0 STEP -C
PORTB = A
NEXT A
DIM A AS
BYTE
loop:
SELECT
CASE A
CASE 255
A = 1
CASE <=
127
A = A + 1
CASE ELSE
A = 255
ENDSELECT
GOTO loop
After
IF-THEN statement in the same line can be placed almost every other possible
statement and then ENDIF is not used. There are no limits for the number
of nested statements of any kind. In the test expressions of IF-THEN and
WHILE statements it is possible to use multiple ORed and multiple ANDed
conditions. Multiple comma separated conditions can be used with CASE statements,
also.
LOOKUP
function can be used to select one from the list of Byte constants, based
on the value in the index variable, that is supplied as the last separated
argument of the function. The first constant in the list has index value
0. The selected Byte constant will be loaded into the result variable of
the function. If the value in the index variable goes beyond the number
of constants in the list, the result variable will not be affected by the
function. Here is one small example for a 7-segment LED display:
DIM DIGIT
AS BYTE
DIM MASK
AS BYTE
loop:
<