PIC Assembler 10F200 Light an LED Program

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
This next part gets a little involved.

Okay. GPIO is straightforward.

It's on the first chart in Memory Organization. At address 06h.

The 'Tris Register' gets more involved.

At bottom of this graph it says see Indirect Addressing INDF and SFR registers.

Over at the SFR graph. GPIO shows up again.

But. The TRISGPIO shows up this time.

Is TRISGPIO the 'TRIS register"?
 

JohnInTX

Joined Jun 26, 2012
4,787
This next part gets a little involved.

Okay. GPIO is straightforward.

It's on the first chart in Memory Organization. At address 06h.

The 'Tris Register' gets more involved.

At bottom of this graph it says see Indirect Addressing INDF and SFR registers.

Over at the SFR graph. GPIO shows up again.

But. The TRISGPIO shows up this time.

Is TRISGPIO the 'TRIS register"?
On the 10F200, the TRISGPIO (TriState control register for GeneralPurposeIO)register is not memory mapped i.e. it is not accessible using ordinary reads and writes. The way to set the direction of the GPIO pins is to write to the TRISGPIO register and the only way to do that is to use the TRIS GPIO instruction. Note that TRIS is a real register in the bigger PICs that is accessed in the conventional way.

OPTION works in a similar manner i.e. it is only accessible via the OPTION instruction. The presence of N/A in the Address column of table 4-1 is the giveaway. No memory address because the two registers are not mapped in memory.

Note that W is also not directly addressable in these parts so you can't perform register-addressed operations on W (no bcf/bsf/incf/decfsz etc). There are a few specific 'W' oriented instructions like ANDLW et. al. but that's it. In other PICs, W is memory mapped as WREG and works like any other file register.
 
Last edited:

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
start
movlw b'1101' ; configure GP1 (only) as an output
tris GPIO
movlw b'0010' ; set GP1 high
movwf GPIO

A 'head scratcher' question.

See how GPIO is seemingly written to twice?

First time with a TRIS instruction and the second time with a MOVWF.

Where are these values going to? Where do they end up?
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
start
movlw b'1101' ; configure GP1 (only) as an output
tris GPIO
movlw b'0010' ; set GP1 high
movwf GPIO

A 'head scratcher' question.

See how GPIO is seemingly written to twice?

First time with a TRIS instruction and the second time with a MOVWF.

Where are these values going to? Where do they end up?
 

JohnInTX

Joined Jun 26, 2012
4,787
start
movlw b'1101' ; configure GP1 (only) as an output
tris GPIO
movlw b'0010' ; set GP1 high
movwf GPIO

A 'head scratcher' question.

See how GPIO is seemingly written to twice?

First time with a TRIS instruction and the second time with a MOVWF.

Where are these values going to? Where do they end up?
Re-read the detailed descriptions for the TRIS and movwf instructions. One writes W to the port flip-flops, the other writes to the register that sets the direction of the pins. Two different instructions- two different actions.
 
Top