Ibrahim Dogan - Advanced PIC Microcontroller Projects in C

Здесь есть возможность читать онлайн «Ibrahim Dogan - Advanced PIC Microcontroller Projects in C» весь текст электронной книги совершенно бесплатно (целиком полную версию без сокращений). В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Город: Burlington, Год выпуска: 2008, ISBN: 2008, Издательство: Elsevier Ltd, Жанр: Программирование, Компьютерное железо, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.

Advanced PIC Microcontroller Projects in C: краткое содержание, описание и аннотация

Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «Advanced PIC Microcontroller Projects in C»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.

• The only project book on the PIC 18 series using the C programming language
• Features 20 complete, tried and test projects
• Includes a CD-ROM of all the programs, hex listings, diagrams, and data sheets

Advanced PIC Microcontroller Projects in C — читать онлайн бесплатно полную книгу (весь текст) целиком

Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «Advanced PIC Microcontroller Projects in C», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

15. Port RB0 of a PIC18F452 microcontroller is configured as the RS232 serial output port. Write a program to send out string “SERIAL” at 9600 baud.

16. Repeat Exercise 15 but use the hardware USART available on the microcontroller chip.

17. Explain the differences between software-implemented serial data communication and USART hardware-based serial communication.

18. Write a function to add two arrays that are passed to the function as arguments. Store the sum in one of these arrays.

19. Write a function to perform the following operations on two-dimensional matrices:

a) Add matrices

b) Subtract matrices

c) Multiply matrices

20. Write a function to convert between polar and rectangular coordinates.

21. Write functions to convert temperature expressed in Celsius to Fahrenheit and vice versa. Show how these functions can be called from main programs to convert 20°C to °F and also 100°F to °C.

22. Write a program to store the value of function f(x) in an array as x is varied from 0 to 10 in steps of 0.5. Assume that:

f(x) = 1.3x³ – 2.5x² + 3.1x – 4.5

CHAPTER 5

PIC18 Development Tools

The development of a microcontroller-based system is a complex process. Development tools are hardware and software tools designed to help programmers develop and test systems in a relatively short time. There are many such tools, and a discussion of all of them is beyond the scope of this book. This chapter offers a brief review of the most common tools.

The tools for developing software and hardware for microcontroller-based systems include editors, assemblers, compilers, debuggers, simulators, emulators, and device programmers. A typical development cycle starts with writing the application program using a text editor. The program is then translated into an executable code with the help of an assembler or compiler. If the program has several modules, a linker is used to combine them into a single application. Any syntax errors are detected by the assembler or compiler and must be corrected before the executable code can be generated. Next, a simulator is used to test the application program without the target hardware. Simulators are helpful in checking the correctness of an algorithm or a program with limited or no input-outputs, and most errors can be removed during simulation. Once the program seems to be working and the programmer is happy with it, the executable code is loaded to the target microcontroller chip using a device programmer, and the system logic is tested. Software and hardware tools such as in-circuit debuggers and in-circuit emulators can analyze the program’s operation and display the variables and registers in real time with the help of breakpoints set in the program.

5.1 Software Development Tools

Software development tools are computer programs, usually run on personal computers, that allow the programmer (or system developer) to create, modify, and test applications programs. Some common software development tools are:

• Text editors

• Assemblers/compilers

• Simulators

• High-level language simulators

• Integrated development environments (IDEs)

5.1.1 Text Editors

A text editor is used to create or edit programs and text files. The Windows operating system comes with a text editor program called Notepad. Using Notepad, we can create a new program file, modify an existing file, or display or print the contents of a file. It is important to realize that programs used for word processing, such as Microsoft Word, cannot be used for this purpose, since they embed word formatting characters such as bold, italic, and underline within the text.

Most assemblers and compilers come with built-in text editors, making it possible to create a program and then assemble or compile it without having to exit from the editor. These editors provide additional features as well, such as automatic keyword highlighting, syntax checking, parenthesis matching, and comment line identification. Different parts of a program can be shown in different colors to make the program more readable (e.g., comments in one color and keywords in another). Such features help to eliminate syntax errors during the programming stage, thus speeding up the development process.

5.1.2 Assemblers and Compilers

Assemblers generate executable code from assembly language programs, and that generated code can then be loaded into the flash program memory of a PIC18-based microcontroller. Compilers generate executable code from high-level language programs. The compilers used most often for PIC18 microcontrollers are BASIC, C, and PASCAL.

Assembly language is used in applications where processing speed is critical and the microcontroller must respond to external and internal events in the shortest possible time. However, it is difficult to develop complex programs using assembly language, and assembly language programs are not easy to maintain.

High-level languages, on the other hand, are easier to learn, and complex programs can be developed and tested in a much shorter time. High-level programs are also maintained more easily than assembly language programs.

Discussions of programming in this book are limited to the C language. Many different C language compilers are available for developing PIC18 microcontroller-based programs. Some of the popular ones are:

• CCS C (http://www.ccsinfo.com)

• Hi-Tech C (http://htsoft.com)

• C18 C (http://www.microchip.com)

• mikroC C (http://www.mikroe.com)

• Wiz-C C (http://www.fored.co.uk)

Although most C compilers are essentially the same, each one has its own additions or modifications to the standard language. The C compiler used in this book is mikroC, developed by mikroElektronika.

5.1.3 Simulators

A simulator is a computer program that runs on a PC without the microcontroller hardware. It simulates the behavior of the target microcontroller by interpreting the user program instructions using the microcontroller instruction set. Simulators can display the contents of registers, memory, and the status of input-output ports as the user program is interpreted. Breakpoints can be set to stop the program and check the contents of various registers at desired locations. In addition, the user program can be executed in a single-step mode, so the memory and registers can be examined as the program executes one instruction at a time as a key is pressed.

Some assembler programs contain built-in simulators. Three popular PIC18 microcontroller assemblers with built-in simulators are:

• MPLAB IDE (http://www.microchip.com)

• Oshon Software PIC18 simulator (http://www.oshonsoft.com)

• Forest Electronics PIC18 assembler (http://www.fored.co.uk)

5.1.4 High-Level Language Simulators

High-level language simulators, also known as source-level debuggers, are programs that run on a PC and locate errors in high-level programs. The programmer can set breakpoints in high-level statements, execute the program up to a breakpoint, and then view the values of program variables, the contents of registers, and memory locations at that breakpoint.

A source-level debugger can also invoke hardware-based debugging using a hardware debugger device. For example, the user program on the target microcontroller can be stopped and the values of various variables and registers can be examined.

Some high-level language compilers, including the following three, have built-in source-level debuggers:

• C18 C

• Hi-Tech PIC18 C

• mikroC C

5.1.5 Integrated Development Environments (IDEs)

Integrated development environments (IDEs) are powerful PC-based programs which include everything to edit, assemble, compile, link, simulate, and source-level debug a program, and then download the generated executable code to the physical microcontroller chip using a programmer device. These programs are in graphical user interface (GUI), where the user can select various options from the program without having to exit it. IDEs can be extremely useful when developing microcontroller-based systems. Most PIC18 high-level language compilers are IDEs, thus enabling the programmer to do most tasks within a single software development tool.

Читать дальше
Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Похожие книги на «Advanced PIC Microcontroller Projects in C»

Представляем Вашему вниманию похожие книги на «Advanced PIC Microcontroller Projects in C» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.


Отзывы о книге «Advanced PIC Microcontroller Projects in C»

Обсуждение, отзывы о книге «Advanced PIC Microcontroller Projects in C» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.

x