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: view