Thought I would create some tutorials that had more detail. I have been watching the hit rate of various pages and the blink pages seem to get a lot of hits so, thought I would create one with step by step directions how to get an LED to blink using a Blue Bird board.
First of all we are going to need a Blue Bird board. You can get one from here.
Next we are going to need some software. You will need bbtut1.zip from the download section which will give you all the sources you will need to get the LED to blink. So, go get that file and lets get started.
Before you unzip that file we first need to create a project in MPLAB-X. I’ll show you how to do that. First open up MPLAB-X. Then click File/New Project you will see this screen.
Now under Categories select “Microchip Embedded” and under Projects select “Standalone Project”. Click the next button.
You will now see the “Select Device” screen and we need to select the device. The device the Blue Bird board is based on is the PIC24FJ64GB002 so, select this device by first selecting the 16-bit MCUs (PIC24) Family then the PIC24FJ64GB002 Device like this and click Next.
Now we are on the “Select Tool” screen. This screen will show any Microchip debuggers you have attached to your computer. To use the Blue Bird board you don’t need a debugger as it has a built in boot loader. I have a PICkit3 hooked up to my machine so I will select that but, you don’t have to select anything here just click next.
Now we see the “Select Compiler” screen. This is were we select the compiler we are going to use. You should have installed a compiler with your MPLAB-X installation refer to this link for a tutorial on how to install MPLAB X and a compiler. Select the compiler you are going to use. I use the free version of the XC16 compiler. Click next.
Now the “Select Project Name and Folder” screen is the next and final screen. You are almost done with the project creation. This is where we decide where on our disk our project will reside. I have a specific place on my disk where I keep all of my microchip projects. That way I can easily back them up and I know exactly where they are. As you type a “Project Name” you will se a “Project Folder” added to that path also. When you are done selecting your “Project Name” click Finish. Leave the “Set as main project” selected and don’t change the “Encoding”.
We have a project created. Now go find the file bbtut1.zip in your download directory using file explorer. We are going to unzip this file into your project directory.
Double click this file and you should get the following screen.
Click on “Extract all files”. We now have to go to our directory where our project is located. Use the “Browse” button to navigate to your project directory.
Now click “Extract” and close the resulting window. Go back to your MPLAB X and we will now finish setting up the project. You will see the following projects if you look to the left in your MPLAB X window. The project we are interested in is the project you created above. The project I created is “BlueBirdTut1”.
We have to add some files to the projects. We have to add a “Linker Files” and “Source Files” and “Libraries”. I’ll show you how to do this and what files to put where.
Right click on the “Source Files” entry under your newly created project and go to “Add Existing Item…” you will get the following screen.
Click on the “main.c” file and click “Select”.
Now right click on the “Linker Files” and the “Add Existing Item…”.
Select “app_hid_boot_p24FJ64GB002.gld” and Click “Add”.
Now right click on “Libraries” and then “Add Library/Object File…”. You should see this screen.
Your project screen should look like this.
You are now ready to attempt to build the project. And, if your screen looks like the above it should build!
Use the “Hammer and Broom” to test build the project.
You should see the following screen at the bottom of your MPLAB X IDE in the Output pain.
You see that my build was successful. If your build wasn’t successful go back through the above steps and try again or contact us and we will see if we can help.
Our next step is to get the software onto the board and make sure that it works. You will need to down load the Microchip “USB Bootloader”. I have version v2.9j. If you have a newer version I believe it will work. You can find the USB Boot loader here.
With the Blue Bird board you will have to get the boot loader running on it. First plug in a USB cable and attach this to your PC. This will provide power to the board. To do this using the debug board you can press the button closet to the right angle connector or the text describing the board which is the top button and while holding that button press the bottom button. You must hold both buttons and release the top button while holding the bottom button. This will put the Blue Bird board into the boot loader mode.
If you don’t have a debug board you can wire a couple of switch like the following which will accomplish the same thing.
The top button in this image is hooked to the reset. Which is pin 1 on the J2 and GND which is pin 3 on J2. This will reset the processor. There is a pullup on the board so you don’t have to worry about that. The bottom button is hooked to GND via the small jumper between the two switches. The other side of the bottom button is hooked to pin 8 on J1. This pin is the pin the boot loader is looking at to see if it should stay in boot loader mode. The boot loader is using an internal pull up so you don’t have to worry about that either.
The LED is hooked up to pin 6 and has a 470 ohm resistor hooked to the other side of the LED. The 470 ohm resistor is hooked to pin 6 of J1. The software is written such that it will blink the LED.
You should see the following screen. If you don’t have the debug board with your Blue Bird board use the following procedure to put your Blue Bird board into boot loader mode.
You can see that the device is attached and ready to be programmed. If you don’t see this screen try pushing the buttons as described above again. The procedure is a little different but you will get the hang of it.
Next you need to load the file you want to program into the boot loader above. To do this click on the open file Icon. You can find the file in your BlueBirdtut1.X directory in dist\default\production. It is the file that has the .hex extension. Select this file and open it.
Now click the program button which is the middle Icon. You should now have the following screen after programming.
The last thing to do to get your program running is to reset the board which you can use the last Icon on the boot loader or the reset button on your board. Now your program should be running.
That is all there is to it. Hope you enjoyed the trip and learned something along the way.