0% found this document useful (0 votes)
170 views13 pages

New Chapter 3 Programming C

This document provides an overview of PIC programming in C, including: 1) It discusses embedded system applications and the typical hardware and software components, including microcontrollers, real-time operating systems, and embedded system programming. 2) It explains some of the benefits of using C over assembly for embedded programming, such as ease of use, modifiability, and code portability. 3) It outlines the typical steps for programming an embedded system using C, including writing the program, compiling it, burning it onto a microcontroller chip, and testing it on a control circuit. 4) It provides examples of simple C programs and program structures for PIC microcontrollers, as well as explanations of

Uploaded by

Amzar Shukri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
170 views13 pages

New Chapter 3 Programming C

This document provides an overview of PIC programming in C, including: 1) It discusses embedded system applications and the typical hardware and software components, including microcontrollers, real-time operating systems, and embedded system programming. 2) It explains some of the benefits of using C over assembly for embedded programming, such as ease of use, modifiability, and code portability. 3) It outlines the typical steps for programming an embedded system using C, including writing the program, compiling it, burning it onto a microcontroller chip, and testing it on a control circuit. 4) It provides examples of simple C programs and program structures for PIC microcontrollers, as well as explanations of

Uploaded by

Amzar Shukri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

DJM 50122

EMBEDDED SYSTEM APPLICATION

CHAPTER 3
PIC PROGRAMMING IN C
INTRODUCTION
An embedded system is a combination of computer hardware and software designed for a
specific function.
Real-time operating
Software and firmware. system.
Software for embedded systems Real-time operating system.
can vary in complexity. These are not always included
Embedded system programming Hardware in embedded systems,
is computer software, which is especially smaller-scale
The hardware of
used to control devices by systems. RTOSes define how
embedded systems is
providing a set of instructions. the system works by
based around
firmware various devices with supervising the software and
microprocessors and
various functionalities can be setting rules during program
microcontrollers.
programmed using embedded execution.
software, by maintaining design
constraints and storing the final
data in memory (RAM/ ROM).
The following are some of major reason for writing programs in C instead of Assembly:

It is easier and
less time consuming.

C is easier to
modify and update. You can use code
. available in function
libraries.

C code is portable to
other microcontrollers
with little or no
modification
Compile the
Write a program
The following are the steps of program to convert
(example, using it to machine
programming an embedded C language). language
system: (in binary/hex).
01 .

04 02

03
Finally placed the
microcontroller chip on the The program will be burned
control circuit of into a microcontroller chip
the real application for using a special circuit called
example robot arm. programmer/burner.
Example of a simple
program written in C
language:
Example of program
structure in C language
for PIC microcontroller.
FUNCTION
• The main idea is to divide a program into several parts using these functions in
order to solve the actual problem easier.
STRUCTURE
• Every function must be properly declared so as to be properly interpreted during
the process of compilation.
• Declaration contains the following elements:
 Function name
 Function body
 List of parameters
 Declaration of parameters
 Type of function result
.
COMMENT
• Comments are part of the program used to clarify the operation of the program or
provide more information about it.
• Comments are ignored and not compiled into executable code by the compiler.
• The compiler can recognize special characters used to designate where comments
start and terminate and completely ignores the text in between during compilation.
C Data Types
DELAY FUNCTION IN C
• A time delay is something that is very important when working with
embedded applications, because there are times you want a delay before
something is begun.
• Time delays can also be used for breaks between processes. For example,
a time delay in between an LED can make the LED blink on and off, on and off,
repeatedly. So time delays can be very useful and important for embedded
applications.
• A __delay_ms() is not a real function, it is a macro which will expand into in-line
assembly instructions or a nested loop of instructions which will consume the sp
ecified number of time.
EXAMPLE 1

This C program exits in ten seconds, after the printf function is executed the program waits
for 10000 milliseconds or 10 seconds and then it terminates.
EXAMPLE 2

If you don't wish to use delay function then you can use loops to produce delay in a C program.
Thank you
SEE YOU ON END OF CHAPTER 1

You might also like