PIC10 Model Help

Introduction & Contents

Introduction

The PIC10 series models simulate the behaviour of the following microcontrollers from Arizona Microchip™:

PIC10F202, PIC10F204, PIC10F206, PIC10F208

PIC10F220, PIC10F222

Please note that these devices are based on Microchip's 12 bit processor core (as used in the PIC12C5XX series) and not the 14 bit core used in the PIC16 family.

Datasheets for these devices can be viewed by clicking on appropriate device name, above. The letter suffix for individual part indicates revisions of the part and we have modelled devices based on a particular revision.

Please check the Arizona Microchip website for the latest information and errata on particular devices.

See also

  • Getting Started - Compiler Support and Integration
  • Model Properties (Alphabetical Index)
  • Explanation of Warning Messages
  • Run Time Disassembler

This help file last modified 30th November 2012.


High Level Language Support

The PIC10 model can load program files in many debug formats as well as the exact same hex file that you would program a physical device with. The advantage of using one of the debug formats is that they contain symbolic debug information (source code, variables,etc.) which enables you to not only simulate your system in Proteus but also to single step debug. The following is a summary of supported formats with basic instructions on how to get started.

See Also:

Proteus VSM Tutorial

VSM Studio IDE

By far the easiest way to get set up for simulating in Proteus is through the integrated VSM Studio IDE. This tool is integrated into the Proteus Design Suite, will detect installed compilers and you can directly download and install additional tools from inside the IDE.

Installed compilers are automatically configured by VSM Studio to produce debugging output suitable for driving Proteus VSM. If however you need to make changes all of the compiler options are made available in the Project Setting dialogue inside VSM Studio.

Once you have written some code and compiled your schematic will automatically be programmed with the firmware. You can then both simulate and single step debug inside VSM Studio. Active popups let you add 'schematic snippets' to VSM Studio so that you can view and interact with the simulation while debugging the source code.

See Also:

VSM Studio Tutorial (New Project)

Schematic Only

If you choose or prefer to work in your own IDE and use Proteus VSM only for simulation then several debug formats are available. The process in each case is to produce the required debug file from your compiler and then to load this file as the PROGRAM property in the Edit Component dialogue form of the PIC microcontroller.

If in doubt, opt for COFF. Almost all compilers in the PIC world will generate a COFF file when compiling code for PIC16 variants.

ByteCraft COD Loader

The COD format is owned by Bytecraft Limited. and is a common symbolic debug format used across their full range of cross compilers. It is also supported by the MP-LAB environment and used by other compiler vendors such as CCS and Hitech.

COD files have the extension '.COD' and contain limited symbolic debug information only. To load a COD file into the model, you will need to set the program property with the full filename and extension. e.g.

PROGRAM=MYFILE.COD

Note that VSM COD file loader is able to extract source line number information only; the documented information concerning variable locations and types is incomplete and we are therefore unable to implement a variables window for this format this time.

Hitech PICC and PICC Lite

Hitech ‘C’ can now generate output in the Microchip variant of the COFF format as used by MPLAB. The PICC Lite compiler is available as a free download provides an excellent introduction to ‘C’ programming on the PIC.

COFF files contain full source line number and symbolic debug information. To load a COF file into the model, you will need to set the program property with the full filename and extension. e.g.

PROGRAM=MYFILE.COF

Note that the UBROF file contains absolute paths to the 'C' source files, and problems may arise if the project is moved from one directory to another. The solution is to re-compile the project within IAR workbench.

For more information and compiler downloads visit http://www.htsoft.com.

Crownhill Proton Plus

The Crownhill Proton Plus PIC Basic compiler supports source level debugging with Proteus VSM. The PIC10 model loads the BASIC program itself and also the LST file produced by the compiler in order to establish the memory address of source code lines and program variables.

To load a compiled program file into the model, you will need to set the program property with the full filename and '.BAS' extension. e.g.

PROGRAM=MYFILE.BAS

Note that the list file can contain absolute paths to the BASIC source files, and problems may arise if the project is moved from one directory to another. The solution is to re-compile the project within PIC Basic Plus.

For more information go to http://www.picbasic.org.


Model Properties

The PIC model can be configured via a number of properties, described below.

Not all properties are meaningful for a given PIC device and only those properties that are meaningful for a particular device will be shown on that device’s Edit Component dialogue form.

Alphabetical list of all properties

#____________________________________________________________________________________________________________________________________________________________________________________

Dialogue Form Field : Program File

Default Value : (None)

Units/Type : Filename

Applies To Devices : All

This property specifies the name of the program file that will be loaded into the model. The file extension determines the type of program file that will be loaded. See High Level Language Support for more information.

__________________________________________________________________________________________

Dialogue Form Field : Processor Clock Frequency

Default Value : 1M

Units/Type : Hertz

Applies To Devices : All

This property specifies the clock frequency of the processor. For reasons of efficiency, the clock circuitry (external or internal) is not simulated and the clock rate of the processor is determined solely by this value. This value corresponds to the Q clock frequency, referred to as FOSC in the PIC documentation; the instruction clock is one quarter of this value.

Note that although no clock circuitry is modelled you may still need to set the oscillator type in the configuration word if you want the PIC model to model start-up and wake-up delays.

#__________________________________________________________________________________________

Dialogue Form Field : Program Configuration Word

Default Value : 0x0000

Units/Type : 14-bit integer

Applies To Devices : All

This property specifies an initial configuration word for the PIC processor.

The configuration word is a set of bits burnt in to program memory location 2007h. The value of this property specifies an initial value for the configuration word but this will be over-ridden by any value specified for location 2007h in the program code (hex) file.

Use this property to supply a configuration word where your Intel Hex file doesn’t contain one.

Note that the meaning of the bits within the configuration word is specific to the PIC device.

#__________________________________________________________________________________________

Dialogue Form Field : Randomise Program Memory?

Default Value : No

Units/Type : Boolean

Applies To Devices : All

By default the processor’s program memory is initialised to all 1’s (i.e. 0FFFh in every location) before the program code is loaded.j

When this property is assigned Yes then the processor’s program memory is instead filled with random values before the program is loaded.

#__________________________________________________________________________________________

Dialogue Form Field : Randomise Data Memory?

Default Value : Yes

Units/Type : Boolean

Applies To Devices : All

By default, at ‘power-up’, the General Purpose Registers of the processor are initialised with random values.

When this property is assigned No these registers are instead initialised with zeros (i.e. 00h in every location).

Note that the Special Function Registers (e.g. INTCON, TRISA, etc.) are not affected by this property. These registers are always initialised to their correct power-up values.

#__________________________________________________________________________________________

Dialogue Form Field : Model PIC Start-up Delays?

Default Value : No

Units/Type : Boolean

Applies To Devices : All

In normal operation the PIC has a number of built-in delays at power-on reset and on wake-up from sleep:

1. If the PIC is configured (by its configuration word) to use its built-in RC oscillator as the processor clock then the Oscillator Start-up Timer (OST) produces a 1024 Q-clock cycle delay at both power-up and on wake-up from sleep.

2. If the PWTE bit is enabled in the configuration word then a further 72ms delay is introduced at power-up.

By default the PIC model does not model these delays as they serve no useful purpose for most simulations. However if this property is assigned Yes then all power-up start-up delays (where configured by the configuration word) are modelled.

#__________________________________________________________________________________________

Dialogue Form Field : Model PIC Wake-up Delays?

Default Value : No

Units/Type : Boolean

Applies To Devices : All

In normal operation where a PIC is configured (by its configuration word) to use its built-in RC oscillator as the processor clock then the Oscillator Start-up Timer (OST) produces a 1024 Q-clock cycle delay when the processor comes out of sleep.

By default the PIC model does not model this delay as they serve no useful purpose for most simulations. However if this property is assigned Yes then the OST wake-up delay is modelled.

#__________________________________________________________________________________________

Dialogue Form Field : Generate Q Clock On CLKOUT Pin?

Default Value : No

Units/Type : Boolean

Applies To Devices : All

When assigned Yes the model will generate an instruction clock of period Fosc/4 on the OSC2/CLKOUT pin. Note that this will increase the load on the simulator.

#__________________________________________________________________________________________

Dialogue Form Field : Watchdog Timer Period

Default Value : 18E-3 (18m)

Units/Type : Seconds

Applies To Devices : All

This property specifies the period of the PIC model’s watchdog timer clock.

The default value is the nominal 18ms specified by the PIC documentation. However as the period varies from one device to another as well as with temperature it may be useful to specify an alternative period.

#__________________________________________________________________________________________

Dialogue Form Field : Port Pin Low-High Delay

Default Value : 0

Units/Type : Seconds

Applies To Devices : All

With the real PIC device port pin transitions occur on a particular Q-clock cycle and therefore part way through an instruction cycle. The actual pin timing depends on the pin, the module that is driving it, as well as the electrical characteristics of the circuit.

The PIC model performs all port pin transitions synchronous to the start of the instruction cycle plus a delay. This property specifies this delay for a low-to-high transition of the pin.

The default value of zero means that where an instruction causes a transition on an output pin the transition occurs at the very start of the same instruction cycle.

#__________________________________________________________________________________________

Dialogue Form Field : Port Pin High-Low Delay

Default Value : 0

Units/Type : Seconds

Applies To Devices : All

This property is similar to the PORTTDLH property above except that it specifies the delay for a high-to-low pin transition.


Model Properties Index

The following is a complete list of all properties supported by the PIC10 model:

  • Generate Q Clock On CLKOUT Pin
  • Model PIC Start-up Delays
  • Model PIC Wake-up Delays
  • Port Pin High-Low Delay
  • Port Pin Low-High Delay
  • Processor Clock Frequency
  • Program Configuration Word
  • Program File
  • Randomise Data Memory
  • Randomise Program Memory
  • Watchdog Timer Period


Run Time Disassembler

Run Time Disassembler

The PIC10 series model includes a run-time disassembler. The model disassembles the current instruction (that is, the instruction at the current value of PC, the next instruction to be executed) and displays the disassembly at the top of its ‘Registers’ pop-up.

This runtime disassembly has a number of useful functions:

  • The disassembly evaluates addresses using the current values of the RP0, RP1 bits (the bank select bits for a direct address) and IRP bit (the bank select bit for an indirect address). Thus the address shown in the run time disassembly is the ‘real’ address that the instruction will be use and may be different to the register/address shown in the source code. For example, the source code:

    BCF STATUS, RP1
    BSF STATUS, RP0
    …
    MOVWF PORTA

    actually moves the W register in to the TRISA register (as bank 1 is currently selected).
  • Where the destination of an instruction is the INDF (indirect) register the indirect address is disassembled and displayed as follows:

    MOVWF INDF:0x0070
    BSF INDF:INTCON,GIE

    The first example shows the move of W to the INDF register where the indirect address (taking account of the IRP bit) evaluates to 0x0070. The second example shows setting a bit seven of the INDF register which (again, taking account of the IRP bit) evaluates to the address of the INTCON register. As bit 7 of the INTCON register is the GIE bit this is shown literally.
  • Where the destination of an instruction is the read or write of general purpose register that actually maps to another bank this is shown as follows:

    MOVWF 0x01FF (0x00FF)

    In this example, the W register is being moved to location 0x01FF - an address in bank 3. On this particular PIC device, bank 3 addresses are mapped to bank 2 and thus the ‘real’ destination is address 0x00FF.


Warning Messages

The PIC model may issue a warning message when it detects illegal or ambiguous behaviour. The display of messages is controlled by the values of various Model Properties.

An alphabetical list of all warnings issue by the model are listed below.

____________________________________________________________________________________________

Attempt to execute illegal opcode (<opcode>) - NOP executed.

An attempt has been made to execute an instruction op-code that does not decode to any known PIC instruction. The value of PC and the op-code itself are indicated. The model executes a no-operation (NOP) instead.

____________________________________________________________________________________________

Attempt to read unimplemented memory location <address> ignored.

An instruction has attempted to read a memory location that is not implemented on the PIC device. The model reads a value of zero instead.

____________________________________________________________________________________________

Configuration word bits <bits> (bits <bitrange>,<value>) and <bits> (bits <bitrange>,<value>) should be identical.

The configuration word contains different bit values in bit locations that are supposed to be identical. The message indicates the bits that are different.

____________________________________________________________________________________________

Indirect write of <data> to address <address> is itself an indirect write.

An instruction attempted to write data to the IND (indirection register) register when the FSR register (the indirection address register) addresses the IND register. Such a write operation would be recursive and so does not occur.

____________________________________________________________________________________________

PC (<address>) is outside program memory for GOTO/CALL instruction.

PC (<address>) is outside program memory for current instruction.

The new value of PC for the current GOTO, CALL or other instruction is an address outside the PIC’s code memory. As per the PIC documentation, the PC register will wrap around the code memory.

____________________________________________________________________________________________

PORT<pin> is not configured as a analog input.

An ADC conversion is about to take place on a channel pin that is not configured as an analogue input. Whilst the PIC documentation states that conversion of a digital input is allowed it doesn’t state what happens for a conversion on a pin that is a digital output. The PIC model will continue with the conversion and will yield a result based on the voltage of the analogue node the pin is connected to.

____________________________________________________________________________________________

Stack overflow executing CALL instruction.

Stack overflow pushing return address of interrupt.

A CALL instruction has been executed or an interrupt cycle has commenced when there isn’t sufficient space on the PIC’s hardware stack to hold the return address. As per the documentation the stack pointer is wrapped so that the return address is pushed on to the stack at the first stack position.

____________________________________________________________________________________________

Stack underflow executing RETLW instruction.

Stack underflow executing RETURN instruction.

Stack underflow executing RETFIE instruction.

A RETLW, RETURN or RETFIE instruction has been executed when there is no return address currently held on the PIC’s hardware stack. As per the documentation, the model pops the first entry of the stack (a random value or the value remaining from a previous operation) as the return address and wraps the stack pointer to the end of the stack.


Bad or Unsupported PROGRAM Property Extension

Unsupported PROGRAM Property Extension

The program filename extension is missing or is of an unsupported type. The supported extensions are HEX, COF, COD, D39 (UBROF) and BAS.

See Also: High Level Language Support


Program Property Not Specified

In order to load your program into the PICMicro™ microcontroller model, you must enter the compiled program filename into the PROGRAM field of the edit component dialog form. The program filename will be a HEX, COF, COD, UBROF or BAS file.

See Also: High Level Language Support