PIC10F200 microcontroller reference

Overview

AttributeValue
Program memory256 words
Data memory16 bytes
Stack2 deep, 8 bits wide
Pin count6 (4 I/O)
Peripherals1 8-bit timer
Internal clock frequency4MHz
Supply voltage2.0V — 5.5V
Mode (w/ no output load)I @ 2VI @ 5V
Operational mode175μA630μA
Sleep mode0.1μA0.35μA
PinInput?Output?Wake from sleep?Weak pullup?
GP0
GP1
GP2
GP3

If multiple functions are enabled on pin 3, the following order of presidence is used:

1. --
2. Supply voltage (V’DD)
3. GP2 / TMR0 input / F’OSC output (GP2)
4. GP1 / ICSP clock (GP1)
5. GP0 / ICSP data (GP0)
6. --
7. Ground (GND)
8. GP3 / ICSP power / ~MCLR (GP3)

Clock

The PIC10F200 has a single clock option, an internal oscillator with a nominal frequency of 4MHz. The mean frequency of the internal oscillator is 4MHz. Tolerances are:

Each instruction takes four clock cycles to execute.

A decoupling capacitor of 0.1μf or 0.01μf should be placed to bridge the power and ground wires as close to the microcontroller as possible, which will filter out voltage source noise and improve oscillator stability.

Program memory

Addresses 0x0000..0x00FE are program memory. Address 0x00FF is the reset vector, which contains an oscillator calibration value encoded as a MOVLW instruction. Addresses 0x0100..0x01FF are not physically implemented, and accessing them will instead wrap back around into the 0x0000..0x00FF address range.

The program counter is 9 bits, but only the lower 8-bits are used by the PIC10F200, due to the 256-word ROM size. The stack has two levels.

Data memory

AddrInitialNameDescription
0x00xxxx xxxxINDFIndirect access to register defined in FSR
0x01xxxx xxxxTMR08-bit real-time clock
0x021111 1111PCLProgram counter (least-significant-byte)
0x030--1 1xxxSTATUSGPWUF, , , ~TO, ~PD, Z, DC, C
0x04111x xxxxFSRMemory address pointer for indirect access
0x051111 1110OSCCALCAL6, CAL5, CAL4, CAL3, CAL2, CAL1, CAL0, FOSC4
0x06---- xxxxGPIO, , , , GP3, GP2, GP1, GP0
07..0F---- ------Unimplemented
10..1F0000 0000--General purpose registers
------ 1111TRISGPIO, , , , GP3, GP2, GP1, GP0
--1111 1111OPTION~GPWU, ~GPPU, T0CS, T0SE, PSA, PS2, PS1, PS0

The program counter is incremented each cycle, and will always contain the address of the next instruction to be executed.

STATUS register

Mnem.NameIf value is 1...If value is 0...
GPWUFGPIO wake-up flagGPIO-wake-up occurredOther reset occurred
~TOTime-out flagPower-up/CLRWDT/SLEEP occurredWatchdog timeout occurred
~PDPower-down flagPower-up/CLRWDT occurredSLEEP occurred
ZZero flagResult of operation was 0Non-zero result
DCDigit carry flag
CCarry flag

OPTION register

Mnem.NameIf value is 1...If value is 0...
~GPWUGPIO wake-up enableDisabledEnabled for GP0/1/3
~GPPUGPIO weak pull-up enableDisabledEnabled for GP0/1/3
T0CSTimer0 clock source selectUses T0CKI pin inputUses instruction cycle
T0SETimer0 source edge selectUses T0CKI falling edgeUses T0CKI rising edge
PSAPre-scaler assignmentAssigned to watchdog timerAssigned to Timer0
PS[2..0]Pre-scaler rate selectSee belowSee below

This table describes the behaviour of the pre-scaler rate select bits. The TMR0 column applies if the pre-scaler has been assigned to Timer0, or WDT for the watchdog timer.

PS[2..0]TMR0WDT
0001:21:1
0011:41:2
0101:81:4
0111:161:8
1001:321:16
1011:641:32
1101:1281:64
1111:2561:128

OSCCAL register (oscillator calibration)

Configures the internal 4MHz oscillator. The 7-bit value spread over CAL[6..0] is a signed integer used to skew the frequency of the internal oscillator, as shown in the table below. Positive skew increases the frequency, negative skew reduces the frequency, and skew of 0 is nominal frequency.

CAL[6..0] valueSkew value
01111111+127 skew
00000001+1 skew
00000000+0 skew
11111111-1 skew
10000000-127 skew

If FOSC4 is set to 1, every fourth pulse of the internal oscillator will be output on pin 3 (GP2).

TRISGPIO register

Configures the input/output mode for each GPIO pin. This register has no physical address, and can only be set by setting W to the desired value and then calling TRIS f, where f can be either 6 or 7. I think 6 is the one we want. A value of 1 will set a pin to input mode, and a value of 0 will set a pin to output mode.

GPIO register

Writing to the GPIO register will set the output state of each pin, even when the pin is set to input mode. Reading from the GPIO register will always read in the external voltage of that pin, even when the pin is set to output mode.

Be careful when using this register with instructions that are implemented internally as a read followed by a write (BCF and BSF are two such examples). The read will read in the input values of the pins, and the output will set the output states of the pins. This is only an issue if a pin is initially used as an input pin but is later changed over to be an output pin, as the output state will now be unknown.

Reset types

Power-on-reset

TODO.

Device reset timer

TODO.

Watchdog timer

TODO.

Timer 0 (TMR0)

TODO.

PIC10F200 programming reference

In Program/Verify mode, the program memory space encompasses:

Addr
0x0000..0x00FFUser program memory
0x0100..0x0103User ID locations (each 12-bits wide)
0x0104Back-up OSCCAL value
0x0105..0x013FReserved
0x0140..0x01FENot physically implemented
0x01FFConfiguration word

The ‘User ID’ locations are designed to hold identifiers to be read by external program verification tools.

The ‘Back-up OSCCAL value’ exists to make possible the reading of the oscillator callibration value even whilst code protection is enabled.

The Configuration Word register is physically located at 0x01FF, and is only available during Program mode entry. After the program counter has been incremented past this address the register will no longer be available, regardless of the value of the program counter. By convention, the configuration word is stored at logical address 0x0FFF in the ROM file, and it is the responsibility of the programmer software to translate this address over to the proper physical address during programming.

Methods for entering Program/Verify mode

The V’PP-first method prevents the device from executing code prior to entering Program/Verify mode, as code execution is likely to prevent correct entry into Program/Verify mode.

The V’DD-first method allows entry into Program/Verify mode without first needing to disconnect power from V’DD.

To exit Program/Verify mode, drop voltage of ICSP’PWR to operating voltage or lower.

Programming commands are 6-bits wide. Commands followed by data require a delay of 1μs ater the command, followed by 16 clock pulses to transmit the start bit, 14 data bits, and an end bit.

Commands and data are transmitted in little-endian, with the data pin latching on the falling edge of the clock. A hold period of 1μs with the data pin remaining unchanged is required on either side of the clock falling-edge.

A delay of 100μs is required after every ‘End Programming’ command.

The data values of the start and end bits are ignored.

During ‘Read’ commands, the ICSP’DAT pin changes from input mode to output mode at the rising-edge of the 2nd data clock (the first data clock after the Start bit), and returns to input mode at the rising edge of the 16th data clock (the Stop bit).

Minimum of 100ns delay between data change and clock falling-edge, and between clock falling-edge and next data change.

Commands

Note: Command bits are denoted here in little-endian, which is the order in which they are to be transmitted.

NameCommandData
Load Data for Program Memory0 1 0 0 x x
Read Data from Program Memory0 0 1 0 x x
Increment Address0 1 1 0 x x
Begin Program0 0 0 1 x x
End Program0 1 1 1 x x
Bulk Erase Program Memory1 0 0 1 x x

Note TODO: Load, then Begin, then 2ms, then End, then Incr., then rinse+repeat.

The ‘Write Progam’ command loads a 12-bit value into the current memory word. The two most significant bits of the data word are ignored.

The ‘Read Program’ command outputs the value of the current memory word.

The ‘Bulk Erase Program’ command fills the program memory, the oscillator callibration instruction (at 0x00FF), and the configuration word (at 0x01FF) with all 1’s, taking 10ms.

End Program terminates the programming process. A delay of 100μs is required before issuing the next command in order to allow the programming voltage to dissipate.

Instruction set

33 instructions, 12-bits wide.

Mnem.OldWordDescriptionStatus
ADDwADDWF,00001 110f ffffW=W+fC/DC/Z
ADDfADDWF,10001 111f fffff=W+fC/DC/Z
ANDwANDWF,00001 010f ffffW=W&fZ
ANDfANDWF,10001 011f fffff=W&fZ
ANDkANDLW1110 kkkk kkkkW=W&kZ
BCLRBCF0100 bbbf fffff[b]=0--
BSETBSF0101 bbbf fffff[b]=1--
BSKP0BTFSC0110 bbbf ffffJump 1 if f[b]==0--
BSKP1BTFSS0111 bbbf ffffJump 1 if f[b]==1--
CALLCALL1001 kkkk kkkk--
CLRwCLRW0000 0100 0000W=0Z=1
CLRfCLRF0000 011f fffff=0Z=1
CLRWDTCLRWDT0000 0000 0100WDT=0~TO/~PD
DECwDECF,00000 110f ffffW=f-1Z
DECfDECF,10000 111f fffff=f-1Z
DECZwDECFSZ,00010 110f ffffW=f-1, jump 1 if 0--
DECZfDECFSZ,10010 111f fffff=f-1, jump 1 if 0--
EORwXORWF,00001 100f ffffW=W^fZ
EORfXORWF,10001 100f fffff=W^fZ
EORkXORLW1111 kkkk kkkkW=W^kZ
GOTOGOTO101k kkkk kkkk--
NOPNOP0000 0000 0000----
NOTwCOMF,00010 010f ffffW=~fZ
NOTfCOMF,10010 011f fffff=~fZ
INCwINCF,00010 100f ffffW=f+1Z
INCfINCF,10010 101f fffff=f+1Z
INCZwINCFSZ,00011 110f ffffW=f+1, jump 1 if 0--
INCZfINCFSZ,10011 111f fffff=f+1, jump 1 if 0--
IORwIORWF,00001 000f ffffW=f-OR-WZ
IORfIORWF,10001 001f fffff=f-OR-WZ
IORkIORLW1101 kkkk kkkkW=W-OR-kZ
ROLwRLF,00011 010f ffffC
ROLfRLF,10011 011f ffffC
RORwRRF,00011 000f ffffC
RORfRRF,10011 001f ffffC
SETwMOVF,00010 000f ffffW=fZ
SETfMOVWF0000 001f fffff=W--
SETkMOVLW1100 kkkk kkkkW=k--
SUBwSUBWF,00000 100f ffffW=f-WC/DC/Z
SUBfSUBWF,10000 101f fffff=f-WC/DC/Z
SWPwSWAPF,00011 100f ffffW=f[3..0,7..4]--
SWPfSWAPF,10011 101f fffff=f[3..0,7..4]--
TESTfMOVF,10010 001f ffffZ=(f==0)Z
OPTIONfOPTION0000 0000 0010OPTION=W--
RETkRETLW1000 kkkk kkkkReturn, W=k--
SLEEPSLEEP0000 0000 0011Enter standby mode~TO/~PD
TRISfTRIS0000 0000 0ffff=W (f=6,7)--

Test program for PIC10F200

Preamble

%ADDw:f    [ 0001 110f ffff ]
%ADDf:f    [ 0001 111f ffff ]
%ANDw:f    [ 0001 010f ffff ]
%ANDf:f    [ 0001 011f ffff ]
%ANDk:k    [ 1110 kkkk kkkk ]
%BCLR:f:b  [ 0100 bbbf ffff ]
%BSET:f:b  [ 0101 bbbf ffff ]
%BSKP0:f:b [ 0110 bbbf ffff ]
%BSKP1:f:b [ 0111 bbbf ffff ]
%CALL:k    [ 1001 kkkk kkkk ]
%CLRw      [ 0000 0100 0000 ]
%CLRf:f    [ 0000 011f ffff ]
%CLRWDT    [ 0000 0000 0100 ]
%DECw:f    [ 0000 110f ffff ]
%DECf:f    [ 0000 111f ffff ]
%DECZw:f   [ 0010 110f ffff ]
%DECZf:f   [ 0010 111f ffff ]
%EORw:f    [ 0001 100f ffff ]
%EORf:f    [ 0001 100f ffff ]
%EORk:k    [ 1111 kkkk kkkk ]
%GOTO:k    [ 101k kkkk kkkk ]
%NOP       [ 0000 0000 0000 ]
%NOTw:f    [ 0010 010f ffff ]
%NOTf:f    [ 0010 011f ffff ]
%INCw:f    [ 0010 100f ffff ]
%INCf:f    [ 0010 101f ffff ]
%INCZw:f   [ 0011 110f ffff ]
%INCZf:f   [ 0011 111f ffff ]
%IORw:f    [ 0001 000f ffff ]
%IORf:f    [ 0001 001f ffff ]
%IORk:k    [ 1101 kkkk kkkk ]
%ROLw:f    [ 0011 010f ffff ]
%ROLf:f    [ 0011 011f ffff ]
%RORw:f    [ 0011 000f ffff ]
%RORf:f    [ 0011 001f ffff ]
%SETw:f    [ 0010 000f ffff ]
%SETf:f    [ 0000 001f ffff ]
%SETk:f    [ 1100 kkkk kkkk ]
%SUBw:f    [ 0000 100f ffff ]
%SUBf:f    [ 0000 101f ffff ]
%SWPw:f    [ 0011 100f ffff ]
%SWPf:f    [ 0011 101f ffff ]
%TESTf:f   [ 0010 001f ffff ]
%OPTIONf   [ 0000 0000 0010 ]
%RETk:k    [ 1000 kkkk kkkk ]
%SLEEP     [ 0000 0000 0011 ]
%TRISf:f   [ 0000 0000 0fff ]

Blinker Program

TODO