Claus Kuhnel BASCOM. Programming of Microcontrollers with Ease. An Introduction by Program Examples

Similar documents
Embedded Systems. Software Development & Education Center. (Design & Development with Various µc)

Ali Karimpour Associate Professor Ferdowsi University of Mashhad

SBC - Single Board Computer

PIC Microcontroller and

Ali Karimpour Associate Professor Ferdowsi University of Mashhad

WIZTECH AUTOMATION SOLUTIONS (P) LTD., An ISO 9001:2000 and IAO certified company

Figure 1. A test controller communicates with User I/O, the DUT, a DMM, and a PC (for program development).

Introduction to Microcontroller Apps for Amateur Radio Projects Using the HamStack Platform.

Microcontrollers. Principles and Applications. Ajit Pal +5 V 2K 8. 8 bit dip switch. P2 8 Reset switch Microcontroller AT89S52 100E +5 V. 2.

Microcontroller basics

Programming 8-bit PIC Microcontrollers in С

1a)[2] Connect the devices on the left column to items on the right column. Keypad 4x4

Acknowledgments About the Author

ELEG3923 Microprocessor Ch.0 & Ch.1 Introduction to Microcontroller

ELC4438: Embedded System Design Embedded Processor

MAKING PIC MICROCONTROLLER INSTRUMENTS AND CONTROLLERS

ELCT708 MicroLab Session #1 Introduction to Embedded Systems and Microcontrollers. Eng. Salma Hesham

An Arduino Controlled 1 Hz to 60 MHz Signal Generator

ECE3120: Computer Systems Hardware & Software Development Tools

EMBEDDED SYSTEMS: Jonathan W. Valvano INTRODUCTION TO THE MSP432 MICROCONTROLLER. Volume 1 First Edition June 2015

Development Tools. 8-Bit Development Tools. Development Tools. AVR Development Tools

LED Matrix Scrolling using ATmega32 microcontroller

2011 Pearson Higher Education, Mazidi, Naimi, and Naimi Pearson Higher Education, 2011 Pearson Higher Education,

DS-251 In-Circuit Emulator

Diploma in Embedded Systems

Basic Components of Digital Computer

MICROCONTROLLER DESIGN MANUAL

BASIC INTERFACING CONCEPTS

UVI51: A SIMULATION TOOL FOR TEACHING/LEARNING THE 8051 MICROCONTROLLER

LIN bus board datasheet EB

PROGRAMMING AND CUSTOMIZING

EMBEDDED Systems. Functions. MODULE- 1 C programming with data Structure Introduction to C. Array and String. Control Flow Statements In C

Programming in the MAXQ environment

Automation Engineers AB Pvt Ltd, NOIDA Job-Oriented Course on Embedded Microcontrollers & Related Software Stack

Design and Simulation of Temperature Data Acquisition System based on Proteus. Jinghui Su

FIFTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLOGY-MARCH 2014 EMBEDDED SYSTEMS (Common for CT,CM) [Time: 3 hours] (Maximum marks : 100)

THE AVR MICROCONTROLLER AND EMBEDDED SYSTEMS. Using Assembly and С

Microcontrollers. Microcontroller

acret Ameya Centre for Robotics & Embedded Technology Syllabus for Diploma in Embedded Systems (Total Eight Modules-4 Months -320 Hrs.

AVR MICROCONTROLLER PROJECT TUTORIAL E-PUB

Microprocessors/Microcontrollers

Embedded System Current Trends

Advanced Embedded Systems

Battleship. Magnus Hultin, Adam Johansson. Supervisor: Bertil Lindvall

AT89S8252 Development Board V1.0. Manual

Chapter 1. Microcontroller Overview

INDUSTRIAL TRAINING:6 MONTHS PROGRAM TEVATRON TECHNOLOGIES PVT LTD

VLSI Design Lab., Konkuk Univ. Yong Beom Cho LSI Design Lab

EE 354 Fall 2015 Lecture 1 Architecture and Introduction

SECURE DIGITAL ACCESS SYSTEM USING IBUTTON

AC : INFRARED COMMUNICATIONS FOR CONTROLLING A ROBOT

Computer Hardware Requirements for Real-Time Applications

MSP430 Microcontroller Basics

MECE336 Microprocessors I

USER GUIDE. Atmel QT1 Xplained Pro. Preface

UNIT V MICRO CONTROLLER PROGRAMMING & APPLICATIONS TWO MARKS. 3.Give any two differences between microprocessor and micro controller.

eblocks A Adaptor Board datasheet Matrix Multimedia Adaptor Board Contents

Embedded Systems. Embedded Programmer. Duration: 2 weeks Rs Language and Tools. Embedded System Introduction. Embedded C programming

8051 MICROCONTROLLERS

USER GUIDE. Atmel QT6 Xplained Pro. Preface

MicroProcessor. MicroProcessor. MicroProcessor. MicroProcessor

TEVATRON TECHNOLOGIES PVT. LTD Embedded! Robotics! IoT! VLSI Design! Projects! Technical Consultancy! Education! STEM! Software!

To install the software please insert the supplied disk or CDROM in your computer and perform the following steps:

8051 Microcontroller

Design of Embedded Systems Using 68HC12/11 Microcontrollers

Embedded Systems, Android & Robotics INTERNSHIP CONTENT

Introduction to 8051 microcontrollers

MTRX3700 Mechatronics

CS-424/580A Microcontrollers and Robotics

Embedded Robotics. Software Development & Education Center

Figure 1.1: Some embedded device. In this course we shall learn microcontroller and FPGA based embedded system.

Workshop on Microcontroller Based Project Development

Project design tutorial (I)

AVR Training Board-I. VLSI Design Lab., Konkuk Univ. LSI Design Lab

Session 1520 EXPERIENCE OF TEACHING THE PIC MICROCONTROLLERS

Card Reader Board EB037-00

QT3 Xplained Pro. Preface. Atmel QTouch USER GUIDE

Microprocessors And Microcontrollers (Practical)

ATmega128. Introduction

AVR- M16 development board Users Manual

An Introduction to Designing Ham Radio Projects with PIC Microcontrollers. George Zafiropoulos KJ6VU

Microprocessors And Microcontroller

Input/Output Ports and Interfacing

Section 1 AVR Studio User Guide

Robotics Training Module ABLab Solutions

Lecture 1. Course Overview and The 8051 Architecture

COMP3221: Microprocessors and. and Embedded Systems. Instruction Set Architecture (ISA) What makes an ISA? #1: Memory Models. What makes an ISA?

Embedded Systems Lab Lab 1 Introduction to Microcontrollers Eng. Dalia A. Awad

Microprocessor Theory

AC : INTEGRATION OF FREESCALE MICROCONTROLLERS INTO THE ELECTRONICS AND COMPUTER TECHNOLOGY CURRICULUM

COMP2121 Introductory Experiment

Introduction the Serial Communications Parallel Communications Parallel Communications with Handshaking Serial Communications

EMBEDDED SYSTEM BASICS AND APPLICATION

SANKALCHAND PATEL COLLEGE OF ENGINEERING, VISNAGAR. ELECTRONICS & COMMUNICATION DEPARTMENT Question Bank- 1

ECE 354 Computer Systems Lab II. Interrupts, Strings, and Busses

Atmel AVR datasheet. Matrix Multimedia Atmel AVR Board EB Contents

ITT Technical Institute. ET2640 Microprocessors and Microcontrollers Onsite and Online Course SYLLABUS


Computer Hardware Requirements for ERTSs: Microprocessors & Microcontrollers

Introduction. Chapter 1

Transcription:

Claus Kuhnel BASCOM Programming of Microcontrollers with Ease An Introduction by Program Examples

Publisher and author assume no responsibility for any errors that may arise from the use of devices and software described in this book. All rights reserved. No part of this work may be reproduced in any form except by written permission of the author. All rights of translation reserved. 2001 Claus Kuhnel 2

Preface The microcontroller market knows some well introduced 8-bit microcontroller families like Intel's 8051 with its many derivatives from different manufacturers, Motorola's 6805 and 68HC11, Microchip's PICmicros and Atmel's AVR. The 8051 microcontroller family has been well-known over many years. The development of new derivatives is not finished yet. From time to time new powerful derivatives are announced. You will find derivatives from Philips, Dallas, Analog Devices and Cygnal and others with the known 8051 core but enhanced clock and peripherals. For example, complete analog-to-digital and digital-toanalog subsystems were integrated in some chips. Atmel developed the AVR microcontroller family which is well suited for high-level language programming and in-system programming. For all those microcontrollers there is development software ranging from simple assemblers for DOS to integrated development environments for Windows95/98/NT on the market. Apart from programming environments as they are offered, for example, by KEIL, IAR or E-LAB Computer for professional applications, also the more economical and nonetheless sufficiently equipped development environments can maintain ground. BASCOM-8051 and BASCOM-AVR are development environments built around a powerful BASIC compiler which is suited for project handling and program development for the 8051 family and its derivatives as well as for the AVR microcontrollers from Atmel. The programming of microcontrollers using BASCOM-8051 (version 2.0.4.0) and BASCOM-AVR (version 1.11.3.0) will be described in this book. Some applications help understand the usage of BASCOM-8051 and BASCOM-AVR. 3

Acknowledgement I should like to thank the following: in the first place, Mark Alberts of MCS Electronics, who developed the BASCOM programming environment at an outstanding priceperformance ratio, Atmel for the development of the AVR RISC microcontrollers which introduced new capabilities into the microcontroller families, Christer Johansson of High Tech Horizon, who supports safe communication of microcontrollers and PC by the development and free distribution of the S.N.A.P. protocol and the necessary tools effectively and Lars Wictorsson of LAWICEL for the development of the CANDIPs, microcontroller modules with CAN interface. 4

Contents 1 Supported Microcontrollers... 9 1.1 8051 Family... 9 1.2 AVR Family... 11 2 BASCOM... 23 2.1 BASCOM Demos... 23 2.2 BASCOM Commercial Versions... 25 2.3 Update of BASCOM Commercial Versions... 25 2.4 BASCOM Projects... 27 2.4.1 Working on Projects... 27 2.4.2 BASCOM Options... 28 2.5 BASCOM Tools... 37 2.5.1 Simulation... 37 2.5.2 Terminal Emulator... 40 2.5.3 LCD Designer... 42 2.5.4 Library Manager... 46 2.5.5 Programming Devices... 50 2.6 Hardware for AVR RISC Microcontroller... 55 2.6.1 DT006 AVR Development Board... 55 2.6.2 AVR-ALPHA with AT90S2313... 56 2.7 Instead of "Hello World"... 57 2.7.1 AVR... 57 2.7.2 8051... 58 2.7.3 Things in Common... 59 2.7.4 Simulation... 64 2.8 BASCOM Help System... 67 3 Some BASCOM Internals... 69 3.1 Building new instructions... 69 5

3.2 Parameters for Subroutines in BASCOM-AVR... 71 3.3 BASIC & Assembler... 73 3.3.1 AVR... 74 3.3.2 8051... 75 4 Applications... 77 4.1 Programmable Logic... 77 4.2 Timer and Counter... 81 4.2.1 AVR... 81 4.2.2 8051... 104 4.3 LED Control... 107 4.3.1 Single LED... 107 4.3.2 Seven-Segment Displays... 108 4.3.3 Dot-Matrix Displays... 114 4.4 LCD Control... 119 4.4.1 Direct Control... 119 4.4.2 LCD with Serial Interface... 122 4.5 Connecting Keys and Keyboards... 128 4.5.1 Single Keys... 129 4.5.2 Matrix Keypad... 132 4.5.3 PC-AT Keyboard... 136 4.6 Data Input by IR Remote Control... 140 4.7 Asynchronous Serial Communication... 143 4.8 1-WIRE Interface... 151 4.9 SPI Interface... 161 4.10 I 2 C Bus... 167 4.11 Scalable Network Protocol S.N.A.P... 173 4.11.1 S.N.A.P. Features... 174 4.11.2 Description of S.N.A.P. Protocol... 175 4.11.3 S.N.A.P. Monitor... 179 4.11.4 Digital I/O... 183 6

4.12 CANDIP - Interface to CAN... 197 4.13 Random Numbers... 209 4.14 Moving Average... 214 5 Appendix... 219 5.1 Decimal-Hex-ASCII Converter... 219 5.2 DT006 Circuit Diagram... 220 5.3 Characters in Seven-Segment Display... 222 5.4 BASIC Stamp II... 223 5.5 Literature... 224 5.6 Links... 225 6 Index... 231 7