PIC10F200 microcontroller reference
Overview
Attribute | Value |
---|---|
Program memory | 256 words |
Data memory | 16 bytes |
Stack | 2 deep, 8 bits wide |
Pin count | 6 (4 I/O) |
Peripherals | 1 8-bit timer |
Internal clock frequency | 4MHz |
Supply voltage | 2.0V — 5.5V |
Mode (w/ no output load) | I @ 2V | I @ 5V |
---|---|---|
Operational mode | 175μA | 630μA |
Sleep mode | 0.1μA | 0.35μA |
Pin | Input? | 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:
F’OSC
(instruction cycle oscillator output), elseT0CKI
(clock input for timer0), elseTRIS
(GPIO)
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:
- ±1% at 3V and 25°C
- ±2% at 2.5V..5.5V and 0°C..85°C
- ±5% at 2.0V..5.5V and -40°C..85°C
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
Addr | Initial | Name | Description |
---|---|---|---|
0x00 | xxxx xxxx | INDF | Indirect access to register defined in FSR |
0x01 | xxxx xxxx | TMR0 | 8-bit real-time clock |
0x02 | 1111 1111 | PCL | Program counter (least-significant-byte) |
0x03 | 0--1 1xxx | STATUS | GPWUF , — , — , ~TO , ~PD , Z , DC , C |
0x04 | 111x xxxx | FSR | Memory address pointer for indirect access |
0x05 | 1111 1110 | OSCCAL | CAL6 , CAL5 , CAL4 , CAL3 , CAL2 , CAL1 , CAL0 , FOSC4 |
0x06 | ---- xxxx | GPIO | — , — , — , — , GP3 , GP2 , GP1 , GP0 |
07..0F | ---- ---- | -- | Unimplemented |
10..1F | 0000 0000 | -- | General purpose registers |
-- | ---- 1111 | TRISGPIO | — , — , — , — , GP3 , GP2 , GP1 , GP0 |
-- | 1111 1111 | OPTION | ~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. | Name | If value is 1... | If value is 0... |
---|---|---|---|
GPWUF | GPIO wake-up flag | GPIO-wake-up occurred | Other reset occurred |
~TO | Time-out flag | Power-up/CLRWDT /SLEEP occurred | Watchdog timeout occurred |
~PD | Power-down flag | Power-up/CLRWDT occurred | SLEEP occurred |
Z | Zero flag | Result of operation was 0 | Non-zero result |
DC | Digit carry flag | ||
C | Carry flag |
OPTION
register
Mnem. | Name | If value is 1... | If value is 0... |
---|---|---|---|
~GPWU | GPIO wake-up enable | Disabled | Enabled for GP0/1/3 |
~GPPU | GPIO weak pull-up enable | Disabled | Enabled for GP0/1/3 |
T0CS | Timer0 clock source select | Uses T0CKI pin input | Uses instruction cycle |
T0SE | Timer0 source edge select | Uses T0CKI falling edge | Uses T0CKI rising edge |
PSA | Pre-scaler assignment | Assigned to watchdog timer | Assigned to Timer0 |
PS[2..0] | Pre-scaler rate select | See below | See 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] | TMR0 | WDT |
---|---|---|
000 | 1:2 | 1:1 |
001 | 1:4 | 1:2 |
010 | 1:8 | 1:4 |
011 | 1:16 | 1:8 |
100 | 1:32 | 1:16 |
101 | 1:64 | 1:32 |
110 | 1:128 | 1:64 |
111 | 1:256 | 1: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] value | Skew 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
~MCLR
reset during normal operation~MCLR
reset during sleep- Watchdog timer time-out reset during normal operation
- Watchdog timer time-out reset during sleep
- Wake-up from sleep on pin change
Power-on-reset
TODO.
Device reset timer
TODO.
Watchdog timer
TODO.
Timer 0 (TMR0)
TODO.