bascom-avr-theory.pdf
(
6691 KB
)
Pobierz
Microsoft Word - BascomAvrTheory.doc
An Introduction to
Microcontrollers and
Software Design
Name _____________________
MRGS Technology Electronics
Available online from
www.techideas.co.nz
B. Collis - Mount Roskill Grammar School 2003-2009
This work is licensed under the Creative Commons Attribution-Non-commercial-Share Alike 3.0 License. To view a copy of this license, visit
http://creativecommons.org/licenses/by-nc-sa/3.0
. The licensor permits others to copy, distribute and transmit the work. In return, licensees may
not use the work for commercial purposes — unless they get the licensor's permission. The licensor permits others to distribute derivative works
only under a license identical to the one that governs the licensor's work.
Table of Contents
Introduction to Microcontroller Electronics .......................................................................4
What exactly is a Microcontroller .............................................................................6
What you do when learning to program ...........................................................................7
Achievement Objectives from the NZ Curriculum ....................................................8
Hardware - The AVR Microcontroller ...............................................................................9
Power Supplies ........................................................................................................9
AVR Programming .................................................................................................10
Breadboard ............................................................................................................10
Simple AVR circuit .................................................................................................11
Circuit description ..................................................................................................12
AVR programming cable ........................................................................................12
Introduction to writing programs using Bascom-AVR IDE ..............................................13
Reading and Writing using flowcharts....................................................................14
Input and Output Control........................................................................................15
Sending Morse code ..............................................................................................16
Microcontroller ports: write a Knightrider program using 8 LED’s ..........................17
Multiple LEDs - Traffic lights exercise ....................................................................18
Multiple LEDs - 7 Segment Displays......................................................................19
Different types of switches .....................................................................................20
First input device – a single push button switch .....................................................21
BASCOM and AVR Assignment ............................................................................23
Words you need to be able to use correctly when talking about programming ......24
A Bit about Numbers..............................................................................................25
Programming Codes of Practice ....................................................................................26
Programming Template .........................................................................................27
Variables................................................................................................................28
The BASCOM-AVR Simulator................................................................................29
Control statements – IF THEN .......................................................................................31
Connecting and programming multiple switches....................................................31
Reading multiple switches in software ...................................................................32
Using flowcharts to help solve problems................................................................33
Using IF-THEN to control which parts of a program happen..................................37
Debounce ..............................................................................................................36
More Interfacing .............................................................................................................38
Analogue to Digital Conversion..............................................................................39
Reading an LDR’s values in Bascom.....................................................................41
Temperature measurement using the LM35 ..........................................................43
Keypad Interfacing .................................................................................................44
Alternative keypad interface...................................................................................44
Controlling high power loads (outputs)...................................................................45
Parallel Data Communications...............................................................................46
LCDs (Liquid Crystal Displays) ..............................................................................47
Connecting an LCD to a 40pin AVR.......................................................................48
Don’t delay .............................................................................................................51
Programs as solutions: understanding algorithms and flowcharts .................................54
Planning Sequence for an AVR project..................................................................54
One Page Brief ......................................................................................................55
One Page Brief ......................................................................................................56
Algorithm Development Worksheet........................................................................57
Example Brief.........................................................................................................58
Algorithm Planning Example ..................................................................................59
Example Brief.........................................................................................................60
ii
Computers and Microcontrollers ..............................................................................5
Glue Gun Timer Flowchart .....................................................................................62
Multiplication Algorithms ........................................................................................64
Algorithm exercises................................................................................................68
LCD programming exercises..................................................................................69
LCD programming exercises..................................................................................69
Scrolling Message Assignment ..............................................................................70
Strings Assignment ................................................................................................71
ASCII Character Table...........................................................................................73
ASCII Assignment..................................................................................................74
Time.......................................................................................................................77
Sounding Off ..........................................................................................................81
System and Software Design.........................................................................................84
Understanding how simple systems work ..............................................................84
Problem Decomposition Example ..........................................................................85
Statecharts.............................................................................................................87
Token Game – Statechart Design Example ...........................................................90
Serial Communications ..................................................................................................95
RS 232 Serial Communications .............................................................................97
Serial IO using Inkey() .........................................................................................102
Introduction to I2C................................................................................................103
Real Time Clocks.................................................................................................105
DS1307 RTC........................................................................................................107
Arrays ..........................................................................................................................112
Computer Programming detail .....................................................................................115
AVR Internals – how the microcontroller works....................................................116
Interrupts......................................................................................................................120
Polling versus interrupt driven architecture ..........................................................122
Timer/Counters ............................................................................................................123
PWM - Pulse Width Modulation ...........................................................................126
AVR Clock/Oscillator............................................................................................129
Assignment – Maths In The Real World.......................................................................130
Math Assignment - Part 1 ....................................................................................133
Math Assignment - Part 2 ....................................................................................134
Math Assignment - Part 3 ....................................................................................135
Math Assignment - Part 4 ....................................................................................136
Math Assignment - Part 5 ....................................................................................137
Math Assignment - Part 6 ....................................................................................138
Bascom Keyword Reference................................................................................139
AVR Development Boards we can use ........................................................................141
AVR Development Board 2 ..................................................................................144
ATMEGA Development Board 3 ..........................................................................147
ATMEGA16/32 Microcontroller Pin Functions and Connections..........................149
ATMEGA16/32 40pin DIP package– Pin Connections.........................................150
iii
Algorithm Development Example...........................................................................61
Introduction to Microcontroller Electronics
The course is an introductory course for students in design using microcontrollers; it covers both
hardware interfacing and software design.
Microcontrollers are a common electronic building block used for many solutions to needs throughout
industry, commerce and everyday life.
They are found inside aircraft instruments.
They are used extensively within cellular phones, modern
cars,
domestic appliances such as stereos and washing machines
and in automated processes through out industry
4
Computers and Microcontrollers
A microcontroller is very much everything that you would find inside a PC's case, but on a
smaller scale. There is a processor, temporary memory for data (the RAM) and memory for
programs (the ROM).
However don't think that because a microcontroller is smaller than a PC that it is the same
comparison as between a real car and a toy car. The microcontroller is capable of carrying
out millions of instructions every second. And there are billions of these controllers out there
in the world doing just that. You will find them inside cars, stereos, calculators, remote
controls, airplanes, radios, microwaves, washing machines, industrial equipment and so on.
5
Plik z chomika:
kaczor1000
Inne pliki z tego folderu:
Obsługa kolorowego wyświetlacza graficznego 96x64 - BascomAVR cz. 1.pdf
(1169 KB)
Obsługa kolorowego wyświetlacza graficznego 96x64 - BascomAVR cz. 2.pdf
(1081 KB)
Interfejs I2C slave w AVR - BascomAVR.pdf
(528 KB)
Moduł Bluetooth WT12 w praktyce, BascomAVR cz.1.pdf
(1450 KB)
Moduł Bluetooth WT12 w praktyce, BascomAVR cz.2.pdf
(3285 KB)
Inne foldery tego chomika:
ARM
ATM18 [BascomAVR]
BASCOM
Bascom AVR 2.0.7.5 + Patch
BASCOM AVR 2.0.7.8
Zgłoś jeśli
naruszono regulamin