|
PIC10F 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 PIC10F Simulator IDE.
EXAMPLE 1
- Examine demo.bas file from the application folder. This program reads analog value on AN0 analog input and sends formatted output to an external device using software implemented serial communication. File demo.asm was generated using integrated Basic compiler. File demo.hex was generated using integrated assembler.
Define CONF_WORD = 0x00a
Define CLOCK_FREQUENCY = 4
Define OSCCAL_VALUE = 0xfe
Define SEROUT_REG = GPIO
Define SEROUT_BIT = 1
Define SEROUT_BAUD = 9600
Dim an0 As Byte
Dim i As Byte
ADCON0.ANS1 = 0 'setup GP1 pin for digital purposes
loop:
Adcin 0, an0
Serout "Analog value AN0 = "
i = an0 / 100 'get number of 100s in AN0
an0 = an0 Mod 100
i = i + 48 'to get an ascii value of I
Serout i
i = an0 / 10
i = i + 48
Serout i
i = an0 Mod 10
i = i + 48
Serout i, CrLf
WaitMs 1
Goto loop
- Start PIC10F Simulator IDE.
- Click on Options\Select Microcontroller.
- Select 'PIC10F222' and click on Select button.
- 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.
- Select the option Compact Microcontroller View from the Options menu.
- Click on Tools\Microcontroller View. That will open the Microcontroller View window.
- Click on Tools\Software UART Simulation Interface.
- On the opened window click on TX Line label and select GPIO.1 pin.
- With similar procedure select GPIO.2 pin for the RX Line and 9600 for the baud rate.
- Click on Tools\Oscilloscope. That will open the four channel digital oscilloscope window.
- Select Fast mode from the Mode menu.
- Click on Settings\Turn On/Off Oscilloscope Channel 1.
- Select GPIO.1 and then click on Select.
- 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 Simulation\Start. The simulation will start immediately.
- Click on A button associated with GP0/AN0 pin.
- Using the slider change the analog value on this pin and click on Accept button.
- Watch how formatted output is being displayed on the Software UART Simulation Interface window.
- The last three steps can be repeated.
- The simulation can be stopped any time by clicking on Simulation\Stop.
- Try to run the simulation in Step By Step mode while the Basic Compiler window is opened and demo.bas file loaded in the editor. Then use Run To Next Basic Statement command.
- Screenshot: view
|