0% found this document useful (0 votes)
41 views8 pages

Lab 1

Uploaded by

Mariam Ayman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views8 pages

Lab 1

Uploaded by

Mariam Ayman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Lab1: how to use flowcode IDE

Tools: computer has IDE flow code (note you could download the flow code from Flowcode -
Download Flowcode)
To use template f iles, start a new project and choose Open Template

You will be presented with a choice of templates where you can select the most appropriate board
f or your use.
For example, if you're using the BL0011 and BL0114 combo board, navigate to E-blocks2 section
and select BL0011_Combo.
We are now ready to begin Lab 1.
Lab 1: LED flasher
In this Lab we will create an LED f lasher which will introduce you to the most basic Flowcode
f eatures. This will run in simulation and can be downloaded to hardware.
To make an LED f lasher we will simply turn the LED on and off, repeatedly.
Since we are using a template we already have an LED on our simulation panel on our BL0114
board. Ensure that the configuration properties are as seen below.
We will be using the LED connected to PORTA.0
Now we will create our f lowchart.
To make our microcontroller execute code indefinitely we use a while(1) loop in our flowchart.
This loop condition essentially means that whatever code is placed within our loop will execute,
f orever.
You can drag the Loop over to your f lowchart, yet using Templates create the Loop for you. By
def ault the loop command is set to be a while (1) loop, so it does not need any further
conf iguration.
With our while(1) loop added we can now f ocus on turning the LED on and off.
Since an LED is an output, we will use the 'Output' icon.
Drag an output icon across onto your flowchart, as seen below, ensuring it sits within the while
loop.
You will notice a red star on the top 0f the icon

That just means there are changes made since the last save. If you save your project, the star will
disappear. You will now need to configure the output icon. This is done by double clicking it to view
its properties. Our LED is connected to PORTA.0, so we must configure our properties to match
this.
to select a single pin, in this case output to Single Bit 0 click Show advanced options
Finally, since we want to turn the LED on we write a value of '1' in the 'variable or value' box
To make an LED f lash we must turn it on and off.
Place another output icon on your f lowchart, below the original, and configure it as before.
Although this time you should write a value of '0' instead to turn our LED off.
Our f inal step is to add delays.
Microcontrollers operate at very high speeds (a 32 MHz crystal is used on the BL0114 as
standard). The def ault 32MHz crystal makes the PIC operate 8 million instructions per second.
If it were to turn the LED on and off at this speed, we would not be able to see the change
occurring.Therefore, we add delays into our system. We will add a simple 1 second delay.
To add a delay we f ollow the same procedure as adding other icons, but instead drag a 'delay' icon
onto our f lowchart. As before, we double click our 'delay' icon to configure it for the delay we
require. We can see the delay configuration screen below, where we have set a 1 second delay.

Currently we turn our LED on f or 1 second, then we turn it off. However, we do not hold the LED
of f and so it will turn on again very fast. It would therefore appear that the LED is always on.
We must add another delay icon after we turn the LED off, which can be seen in the f inal flowchart
below
The simple LED flasher is now finished.
First we will simulate our program to check it works as required. Then we will write it to hardware,
and get a real LED f lashing. To simulate, we use the buttons seen in the image below.

The 'Play' button begins our simulation. Once in play mode we can pause or stop our simulation.
The two icons on the very right allow us to manually step through our program. As previously
mentioned microcontrollers operate at very high speeds…much faster than we can see!
We of ten need to manually step through each icon in order to check that our program is working
correctly. I like to use the 'F8' key, rather than clicking on the 'step Into' button. If we run our
simulator we will see that our LED flashes on for 1 second, and off for 1 second.
Now that our program has been simulated and is working as required we will download our
rogram to hardware.
With your appropriate hardware connected and configured correctly, you must now program the
device.
In Flowcode it is easy to download our program to hardware.
When downloading code to our device we again have a shortcut toolbar. There are 3 icons in the
programming section of the toolbar, as seen below. The lef t icon compiles our flowchart into a .C
f ile, while the middle icon compiles the Flowchart into a .Hex file.
These two options are useful if you are using Flowcode to create your program, but 3rd party
hardware to f lash your microcontroller.
With this lab we are using Flowcode to flash our microcontroller, and as such we use the right-
hand icon. This compiles and programs our microcontroller in one button press.

Once we select to program the device a new window will appear on the screen detailing the
compilation and programming progress.
When complete you should see the program working as desired on hardware.
If it is not, ensure that you have followed every step in this labl, and that the flowchart is correctly
conf igured.

You might also like