Assembly Programming Help

Status
Not open for further replies.

Thread Starter

JDR04

Joined May 5, 2011
367
Man, I need Help on This one! Some time ago I bought a PICKIT 2 programmer from Microchip and an experimental board (Low Pin Count board with 16F690 on it)

I just cannot get my head around where to start and how to start on all this. I find it somewhat scary. Tried finding somebody in West lothian Scotland to show me how with the offer of a small fee for their patience but no luck. I'm told its best for me to learn assembly programming and use MPLAB IDE etc etc.

Anybody out there with any wise words for me?

Thanks JDR04
 

Markd77

Joined Sep 7, 2009
2,806
There should be a set of tutorials for the low pin count board on the CD that came with it. If not search around a bit. There are also youtube videos, and other information around the web on how to connect it up, start using MPlab, etc.
Give it a go, it's really pretty simple to get started.
I'd recommend Mplab 8.something rather than MPlab X at the moment.
 

JohnInTX

Joined Jun 26, 2012
4,787
JR,
You did not indicate if you had any programming experience so its hard to know where to send you.

Markd77 is right about starting on MPLAB 8.xx MPLABX is great but more of a learning curve. Get 8.xx at: http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en019469

Googlium: http://www.gooligum.com.au/index.html has some nice tutorials but there are lots of others. The Microchip website/forum has many resources as well.

If you are a programming or uCHIP newbie, you don't even need to hook up the board as you can experiment in MPSIM.

Step by step:
Launch MPLAB 8.xx. You get a blank workspace.
Click Project->Project Wizard. Enjoy the happy welcome.. then click Next..
Select 16F690 as the device.
Select Microchip MPASM Toolsuite
Select Create New Project File radio button and enter a project directory and name of project. Next.
At Add existing files to you project click Next.. you don't have any. Click Finish.
You should have a project window open with a bunch of folder icons.. Source Files, Header Files etc. If not open it with View-Project.
Click File-Add New File to Project. Navigate to your project directory. It should be in the 'Jump To' dropdown.
Pick a name.. JR.asm or something. The MPLAB editor opens. Enter this:

Rich (BB code):
    INCLUDE "P16F690.inc"    ; where all of the PIC registers, IO etc are defined
                            ; MPLAB knows where to find this file

    cblock    20h                ; block of constants. Used to define two bytes of RAM starting at 20h
        Abyte:    1            ; declare some RAM
        AnotherByte:1
    endc
        

        ORG    0                ; tells MPASM where to start
    
        nop                    ; step through these
        nop

loop:
        clrf    Abyte        ; init RAM
        clrf    AnotherByte

        movlw    0            ; clear W
        addlw    .1            ; bump it

        movlw    'H'            ; stuff something into RAM that you can see 
        movwf    Abyte        ; in a watch window.
        movlw    'i'
        movwf    AnotherByte        
        goto    loop

        END                    ; denotes end of source
On the MPLAB toolbar, click Debugger->MPSIM. MPSIM will allow you to mess with code without attached hardware..

Take a deep breath and click Project->Build All. When prompted, select Absolute code. It should build with no errors.

Click View->Watch to open a watch window. Click under symbol name and enter the names of the two RAM bytes (Abyte and AnotherByte). Right-click on the watch window bar and select various representations of the same data.

In Edit->Properties select the 'Other' tab and check 'Debugger PC Location..' to highlight the source lines you are stepping.

You are ready! Click STEP (an arrow between { } on the toolbar). Don't see it? Click View->Toolbars->Debug to turn it on.

Step through the code and watch W: on the MPLAB status bar (bottom of the main window) get loaded to 0 then 1. Watch the RAM get loaded to HI. Click View->FileRegisters and examine the line at 0020h. You should see 'HI' in the ASCII area.

You're ready to go. In the data book, read about the ROM and RAM organization. Pay attention to the bank selection requirements etc. that I have ignored for this example (then look at 18F..)
Next, go to the back of the book and read up on the instruction set. Plug a few in and step them to see what they do. Then plug them ALL in and see what they do. Understand the difference between ,f and ,W and assembler syntax.

Muck about a bit in MPSIM then get on to the chip:
Select Configure->Configuration Bits and set up for your particular board (oscillator type etc). Rebuild.
When it comes time to actually run your code, select Debugger->PicKit2 and rebuild. Plug in the board and have at it.

BTW, I just slapped this together so don't take it as exactly good programing practice. When you get past the play stage, look at the Microchip templates to get started... After that.. we'll talk.

Have fun!

As Markd77 said, lots of stuff on the CD but this should get you on your way.
 
Last edited:

t06afre

Joined May 11, 2009
5,934
This document may also be of some help. http://ww1.microchip.com/downloads/en/DeviceDoc/51281d.pdf
By the way. All the 12 lessons in the low pin count demo. Are created as projects. In MPLAB just go to file->open project and then select a lesson folder. As a tip. Then you are up to starting your own programming. ALWAYS create a project. It takes about 15 seconds and it will make the programming more easy
 

Thread Starter

JDR04

Joined May 5, 2011
367
Can I just thank all the folk who have kindly set out here how I may help myself. There is a huge mountain of info for me to go through now so I'll start on it as soon as possible. This forum has always had great people on it who always are willing to share their knoweledge, and for newbies like myself it's a goldmine.

Thanks guys for all the help and no doubt I'll be asking for plenty more in the future. - JDR04
 

absf

Joined Dec 29, 2010
1,968
Not everyone appreciates the helps they get here and some took them for granted.

Allen
 
Last edited:
Status
Not open for further replies.
Top