Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Single- and Multi-Chip Microcontroller Interfacing For the Motorola 68HC12 (G.J. Lipovski, 1999).pdf
Скачиваний:
111
Добавлен:
12.08.2013
Размер:
41.97 Mб
Скачать

2

Programming Microcomputers

We now consider programming techniques used in I/O interfacing. The interface designer must know a lot about them. As the industry matures, the problems of matching voltage levels and timing requirements, discussed in §3.2, are being solved by better-designed chips, but the chips are getting more complex, requiring interface designers to write more software to control them.

The state-of-the-art 6812 clearly illustrates the need for programming I/O devices in a high-level language as well as for programming them in object-oriented languages. The dozen I/O ports and its plethora of SPI, SCI, A-to-D, and timer ports may be a challenge to many assembler language programmers. But the 4K-byte EEPROM memory is large enough to support high-level language programs. Also, object-oriented features like modularity, information hiding, and inheritance will further simplify the task of controlling 6812 systems.

This book develops C and C++ interfacing techniques. Chapter 1, describing the architecture of a microcomputer, has served well to introduce assembler language, although a bit more will be done in this chapter. We introduce C in this chapter. The simplest C programming constructs are introduced in the first section. The handling of data structures is briefly covered in the next section. Programming styles, including the writing of structured, modular, and object-oriented programming, will be introduced in the last section. Subroutines will be further studied as an introduction to programming style. The use of classes in C++ will be introduced at the end of this chapter. While this introduction is very elementary and rather incomplete, it is adequate for the discussion of interfacing hi this text. Clearly, these concepts must be well understood before we discuss and design those interfaces.

For this chapter, the reader should have programmed in some high-level language. From it, he or she should learn general fundamentals of programming in C or C++ to become capable of writing and debugging tens of statements with little difficulty, and should learn practices specifically applicable to the 6812 microprocessor. If you have covered this material in other courses or absorbed it from experience this chapter should bring it all together. You may pick up the material just by reading this condensed version. Others should get an idea of the amount of background needed to read the rest of the book.

45