Flash an LED 10F200 Tutorial

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Baseline PIC Assembler, Lesson 2: Flash an LED Page 9
In lesson 1, we made GP1 high, and left it that way. To make it flash, we need to set it high, then low, and then repeat. You may think that you could achieve this with something like:
flash
movlw b'000010' ; set GP1 high
movwf GPIO
movlw b'000000' ; set GP1 low
movwf GPIO
goto flash ; repeat forever
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
There's the text from tutorial at the first new part in Lesson 2

Note. This code will be corrected next in lesson..

I will look in 10F200 datasheet.

Is GPIO 8 bits wide?

What comes after this is ROUGH!
 

be80be

Joined Jul 5, 2008
2,072
Well that would work if the clock was ticking at about half a second a tick
but at 4 mhz you'll never see it change a scope can
Code:
flash
movlw b'000010' ; set GP1 high
movwf GPIO
movlw b'000000' ; set GP1 low
movwf GPIO
goto flash ; repeat forever
Need a call delay
Code:
flash
movlw b'000010' ; set GP1 high
movwf GPIO
Call delay
movlw b'000000' ; set GP1 low
movwf GPIO
Call delay
goto flash ; repeat forever
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Thank you Max!

Datasheet says GPIO is a 8 bit register.

Only 'low order' bits are used.

Bits 7 through 4 are 'unimplemented'.

Today's new word!

movlw b'000010'

Why are 6 bits being moved?

Just good programming practice?
 

be80be

Joined Jul 5, 2008
2,072
It's a 6 pin chip that comes in a 8 pin package
Using 6 bit's is just lazy writing. Not good anything.
Just makes it easy to make a mistake.
The chip is 8 bit writing 0b000000 or 0b00000000 takes one byte
writing 0b000000 saves nothing but 2 key stokes on the key pad and
It will get you sooner or later.
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Thank you Bebe and Max!

Okay. So writing all 8 bits is more the good programming practice. Got it!

What does GPIO do?

High and low?

Does that mean internally the PIC is opening and closing the circuit for regulated 5 volts for that pin?

Making pin an output was handled earlier.

Tutorial modifies first lesson source code for this second lesson.

I just didn't post that.
 
Last edited:

jayanthd

Joined Jul 4, 2015
945
TRISIO register configures the PORT as Input or Output PORT. GPIO menans General Purpose IO register. It holds the value of the PORT if PORT is configured as input or it sets the PORT state (0 or 1) if PORT is configured as an output port.
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Thank you Jay!

PORT?

Let me look at the tutorial and the datasheet again.

I do not remember PORT.

You have all been warned about what the tutorial does next!:)

Yes. It does put a delay in but that is not the really fun part.

I am going to take a break and dive into that later.
 

jayanthd

Joined Jul 4, 2015
945
A PORT is the hardware which is used for interfacing Input and Output devices like buttons, Leds, etc,...

A PORT has TRISIO and GPIO registers associated with it. It might have other registers like ANSEL, ANSELH, ANSELx in other PIC devices for configuring the PORT or PIN (bits of a PORT) as analog pins.
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Thank you Max and Jay!

Datasheet lists PORT registers on Page 21. 10F200 datasheet.

TRISGPIO

GPIO

Then throws in

OPTION

STATUS

Okay. Now it's breaktime.
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Thank you Max!

'But better not go there!'

That's what is going on with me doing this.

Each little step forward is bringing up questions.

Hard to tell what is important and what isn't at this stage of the game.

Will start at this nice and fresh tomorrow.
 

be80be

Joined Jul 5, 2008
2,072
Baby chip got only gpio big chips got lots ports.
The port is like a programmable transistor well that's what it is
10f200.png
The 10f200 has little to nothing to use and to do a lot with it is not as easy as one would think cause of
hardware limits.
256 fash 16 bytes sram 4 i/o 1 8 bit timer
Not much to work with there.
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Thank you Bebe!

Yes. I did see the schematic of the hardware for a port.

That fits my definition of a 'I am not going to go there.'

Okay. Get ready for part of tutorial here!
 
Top