Your first test

OK, so you set up the software, MPLAB-X.

Run it. Takes a short time to load up.

Now, let's make a project. You don't need any hardware yet, just your PC.

From the menu, select File, then New Project.



Click Next.



Type in the device as shown here, PIC16F15345. Click Next.




Click on Simulator.  Click Next.



You probably won't have many, if any, of these. So click on Download Latest and follow any instructions. A compiler is a piece of software which takes what you write (this will be code in the C language) and compiles it into what the microprocessor understands (this is code in assembler language). We can look at this later.

Once it's finished, you can select the XC8 Compiler and click Finish.




 Now fill in the boxes like this (replace YourName with whatever you log in as). Click Finish.

You'll see a couple of panes like this:

 


OK? Now you've made a project. It won't do anything yet, because you haven't told it what you want it to do, but it knows which microprocessor (the PIC16F15345) you're going to use. The simulator will "run" the compiled code for you, when you've written and compiled it, and you can see what's happening before you even think about buying some nice shiny components.

Now, select from the MM1 Project pane a new source file. Right-click on Source Files, then left-click on New, then C Source File. Like this:



Change the name to MM1:



Click Finish.

You'll now see a black page, called MM1.c, which is going to be your C program.

To compile it, you'll need to put some code in there.

Type this into the source code pane:












You'll get the hang of it soon.

If it's easier, copy and paste this:

void main()
{
   
}


Now, let's compile it. Click Production on the main menu, then Build Main Project.

Something happening? Hope so. A new pane, called "Output", should appear. In there, among other stuff, will be:

Memory Summary:
    Program space        used     9h (     9) of  2000h words   (  0.1%)
    Data space           used     2h (     2) of   400h bytes   (  0.2%)
    EEPROM space         None available
    Data stack space     used     0h (     0) of   3F0h bytes   (  0.0%)
    Configuration bits   used     0h (     0) of     5h words   (  0.0%)
    ID Location space    used     0h (     0) of     4h bytes   (  0.0%)


BUILD SUCCESSFUL (total time: 2s)


Loading completed

and hopefully nothing in red!

Right then, if you got this far, it probably took you several hours, and if you don't feel you're well on the way to being a micromeister, then have a word with yourself.

WELL DONE!

Take a break. Next blog post will be all about what we're going to make this thing do. And you still won't need any hardware, but when you do, it'll actually do something!


Comments

Post a Comment

Popular posts from this blog

Get the software

Lights!