MPLAB X IDE 4.00 Programming 10F200 2017

OBW0549

Joined Mar 2, 2015
3,566
Okay. So EQU is the way 16F84 does it and probably 16Cxx PIC's. 10F200 uses revised way. Got it!!
Absolutely, utterly wrong. PICs don't "use" EQU or CBLOCK or UDATA or any other term you might come across; those things are MPASM assembler directives, and they have very specific, rigorously defined meanings that you can easily find in the MPASM User Manual.

EQU is found on page 81 of the User Manual,

Untitled.png

and it does EXACTLY what the manual says it does under section 4.27.2, no more and no less.

This stuff is really, REALLY easy to understand; all you have to do is RTFM!!!
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Tnank you Bebe!

Use UDATA. Stay away from EQU.

Okay. Now EQU sort of intrigues me.

I can load values to locations in memory and

then look at them in Variable window down the bottom in Lab X.

That would help my confidence in this.
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Thank you OBW!

Two things.

One new thing at a time works best for me. Then repetition with different examples helps a lot too.

Second thing.

Somebody who absolutely positively knows their stuff told me something.

Sometimes people teaching sometimes forget what it is like to be a beginner.

One shot Microchip sentenced don't by a miracle have me going away saying

'Oh. So that's how it works'

Some do but most don't.
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Okay. Moving on to this.

sGPIO res 1 ; shadow copy of GPIO

Let me look up RES in MPASM manual and see if I get it.
 

be80be

Joined Jul 5, 2008
2,395
Here My copy
Code:
This example shows the advantage of
res directive in developing relocatable code. The program calculates the perimeter of a rectangle. Length and width of the rectangle will be stored in buffers addressed by length and width. The calculated perimeter will be stored in the double-precision buffer addressed by perimeter.
  #include p18f452.inc   ;Include standard header file
                         ;for the selected device.
 
  UDATA                  ;This directive allows the
                         ;following data to be placed only
                         ;in the data area.
 
  perimeter  res  2      ;Two locations of memory are
                         ;reserved for the label
                         ;'perimeter'. Addresses of the
                         ;memory locations will be
                         ;allocated by the linker.
  length     res  1      ;One location of memory is
                         ;reserved for the label 'length'.
                         ;Address of the memory location
                         ;will be allocated by the linker.
  width      res  1      ;One location of memory is
                         ;reserved for the label 'width'.
                         ;Address of the memory location
                         ;will be allocated by the linker.
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Thank you Bebe!

How about I take this part with me.

1) That RES goes in the second column.

2) You can put an argument after it for a number of locations.

Then I move on.

Just 'Monkey see. Monkey do; this tutorial.

Quit getting bogged down on almost every sentence.
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Thank you Max!

I was just talking to Bebe about that kind of thing. I think I need a new approach to this. 'Cut and run'.

I think I just need to

1) Just accept the author's explanation.

2) Get to the end and run the code.

3) Then move on.

Maybe I will absorb this somehow.
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Thank you Bebe!

Will dive into this again today.

Actually getting used to it.

Next section is about putting in a delay.

A little bit of doing it one way and then another.

Lot of calculations with megahertz and clock cycles.

Looks like it might be a job for 'Monkey see. Monkey do'.:)
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
The flashing code now becomes:
clrf sGPIO ; clear shadow register
flash
movf sGPIO,w ; get shadow copy of GPIO
xorlw b'000010' ; toggle bit corresponding to GP1 (bit 1)
movwf sGPIO ; in shadow register
movwf GPIO ; and write to GPIO
goto flash ; repeat forever
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
I skipped over CLRF and shadow register.

That's the code for it above.

movf sGPIO,w ; get shadow copy of GPIO

That looks like it copies contents of sGPIO to W register.
 
Top