Flowcode Basic Tutorial
Flowcode Basic Tutorial
1
THE OUTPUT INSTRUCTION
OBJECTIVES
Upon the completion of this lab, you should be able to:
Connect the PORTB of ATMEGA32 to LED board.
Use the OUTPUT instruction and be familiar to the environment of Flowcode
Software.
Configure the correct settings for the target ATMEGA32.
Design a simple program for ATMEGA32.
Simulate the program.
Compile and download the program to ATMEGA32.
Test the program loaded in the ATMEGA32.
EQUIPMENTS
Software:
Flowcode
PPP
BACKGROUND
The ATMEGA32 belongs to a class of 8 bit microcontrollers of RISC architecture.
It has ROM, RAM, EEPROM, Flash memory and two ports namely PORTA which has 5
pins (RA0RA4) and PORTB has 8 pins (RB0RB8). These ports are configurable as
input or output which means there are 13 input/output ports. They are used to interface
to different electronic devices such as LEDs, switches, motors, sensors, LCDs and
keypads.
The basic ATMEGA32 microcontroller circuit requires an oscillator and an
optional reset button. An oscillator is necessary for the ATMEGA32 to work properly
because it is the one that provides the clock pulse and determines how fast the
microcontroller will execute the program loaded to its memory. Resistor-Capacitor (RC),
Crystal and Resonator oscillators are types of oscillators that can be used for
ATMEGA32 micros. The crystal oscillator is the commonly used which ranges from
4MHz to 20MHz.
LEDs with current limiting resistors are connected to microcontroller in two ways.
One is to switch them on with logic zero, and the other using logic one. The value of
resistor is determined by the amount of current that can flow to the LED. The maximum
current flow through the LED is set by the manufacturer.
PROCEDURE
1. Set up the Hardware.
Page 1 of 5
Flowcode will then display the microcontroller in the Microcontroller view and create an
empty flowchart. If the microcontroller is not shown, click ViewChip
the menu. This opens the 'Specify Component Pin Connections' dialogue box, like the one
shown below. This shows which LED is connected to which port, and which bit of the port on
the ATMEGA32micro chip.
Page 2 of 5
Click on the
option in the menu that you see. Notice that the settings for 'ATMEGA32 Port' and
'ATMEGA32 Bit' change for all eight LED's.
Click on the 'Done' button to close the dialogue box.
You can change the color of the LED's by clicking on the
button on the LED display,
arrow by the ' Connect to Port' dialogue box, and select the PORTB
and choosing the 'Properties' option. The following dialogue box opens:
Click on the
arrow at the end of the 'LED Color' box, and select the color you want.
Page 3 of 5
Move the cursor over the 0 in the Variable or value box and click once. This will highlight
the '0'. Now type a number 1 on the computer keyboard to change the value to a 1.
Move the cursor over the
arrow in the Port window. Click on Port B in the menu that
opens up. The dialogue box now looks like the one below.
Page 4 of 5
process. If the Multichip Programmer is properly connected, it should be successful. You will
see the actual output on the LED board.
8. Repeat Step 5 to 7
You can also use Hexadecimal number preceded by 0x. To input 45H, enter 0x45.
For Binary numbers, precede it with 0b followed by 8 bit binary number. For example 45H is
equivalent to 0b01000101 in Binary.
Modify the value of set in the Output icon
into the following:
a. 57
b. 36
c. 15
d. 150
e. 200
f. 0xCD
g. 0xAD
h. 0x1F
i. 0x35
j. 0xA1
Whats the actual output? Which LEDs are ON?
Which LEDs are OFF? Why?
Supplemental Activities
The program should be downloaded to the ATMEGA32 for verification and checking.
1.
2.
3.
4.
5.
6.
Use a single output icon that lights all of the LED's of Port B.
Alter the icon parameters so it puts only the odd LEDs of PortB 'on'
Now put only the even LEDs of PortB 'on'.
Now put the High nibble (bits 4 to 7) of Port B 'on'
Put only the LED on PB7 'on' by sending an 8-bit value to this port.
Write a program with at least 20 Outputs icons that writes a pattern of different
values to port B, one after the other, and review what the result is in simulation.
7. Draw up the full circuit diagram of the ATMEGA32 with 8 LEDs on port B, including
the clocking circuit, the reset circuit, VDD and VSS connected to the ATMEGA32 and
the correct current limiting resistors connected between LED and ATMEGA32.
Page 5 of 5