Re: [Beginner Tutorial] How to get started with PICBASIC PRO Demo, MPLAB & PICKIT 2
There's quite different way to start a new project within MPLAB. Here I'll show how to start a new PicBasic project using a PIC16F690 with the Project Wizard.
- On the top menu, Click on Project
- Select Project Wizard
- Click on Next
- Choose PIC16F690 from the Device drop down list
- Click on Next
- Time to tell MPLAB we'll be using PICBASIC PRO
From the Active Toolsuite drop down list, choose microEngineering PICBASIC PRO Toolsuite... obvious I know.
- Click on Next
- On the right side of Create New Project File field, Click on Browse
- Choose the folder we created to store our codes & project C:\PBP_Prog
- In the Filename Field type LedBlinky
- Click on Save
- Click on Next
- You'll be prompted to add some source code and files... click on Skip
- We're done, Click on Finish
Looks familiar? Great. Now what we need to do, is to create, and add a source code to it.
- On the top menu click on File
- Choose New, this will open a new window called Untitled. Our source code will go there
- Let's give our source code a name.
On the top menu click on File
- Choose Save As
- In the Filename field, type LedBlinky.bas
- Click on Save
Project is created, Source Code file is created, but have a look at the project explorer windows on the left... there's no source code included...yet. There's two way to add/include your source code to it.
- In the project explorer, right click on Source Files and then on Add Files
- On the top menu, click on Project then choose Add Files to the project
Both do the same job, I prefer the right click thing... it's up to you to decide.
Ok so now we should have everything setup up properly and we are now ready to jump on the dark side. BUT before we jump in, as we're going to use a PIC16F690 and Microchip LPC Demo board, it's a good idea to download some references to make friend with
- The PIC16F690 Datasheet
- Microchip's LPC Demo Board User Guide
I assume you have ALL 5 JUMPER installed.
Let's observe the board schematic (PDF page 41)
Is there some gotcha in it? Sure...
- There's no crystal attached to the PIC.
Q. And then?
A. We will need to configure the PIC to work with it's own internal OSC. If we don't do it, the PIC will never run...
- LEDs are attached to some pin who have some enabled by default analog peripheral.
Q. How do you know that?
A. The PIC pinout gives some hints, but It's always a good to have a look in the datasheet,
Section 4.5 PORTC and TRISC Registers (pdf page 78-82)
Table 4-3 resume it really well, you want to dig the datasheet to see how to set them.
Q. What if I don't care about the datasheet and just go ahead typing some code for...what kind problem it may cause?
A. You'll be the really first one on earth
Your milleage may vary, but usually a LED connected to an analog pin doesn't work at all. Have a good look at This thread for more infos.
While we're at it, bookmark This thread in your internet browser. It contains a heap of good info.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks