,
,
CCS PIC “C”
COMPILER TUTORIAL
ADEEL
ANWAR
: Created on 2nd MAY 2010•
I am making this tutorial with the
motivation
that, it will be helpful for
the fellow students and it’s a small
contribution toward students
society.
•
•
I hope and expect that the students
coming afterwards will contribute
further and we will
improve
CONTENTS
•
Basic Tutorial
•
Pic wizard
•
Pic Device Selector
•
Fuses and Interrupts list
•
Serial Port Moniter
:
Note “Basic Tutorial” (for Beginners is sufficient for creating and compiling)
. ( & )
Basic Tutorial
•
Creating new Project
•
Adding Source file
•
Writing and editing source file
•
Compilation
•
RAM/ROM percentage
•
View generated assembly code
(optional)
WE WANT TO CREATE A NEW PROJECT
BLANK SOURCE FILE “prg2 c. ”
“ ” , “ ” & “ ”
HEADER FILES SPECIFING CHIP NO CRYSTAL FREQUENCY SERIAL PORT PARAMETERS RESPECTIVELY MAIN LOOP
“
OBSERVE THESE -” SIGNS WITH main “ ” “while” AND for “ ”
THERE IS ALSO AN ENDING SYMBOL
“ ” , “ ”
GENERALLY THESE SYMBOLS ARE ATTACHED TO ALL THE LOOPS IF ELSE OR ANY “{ }”
“-”
“+” “ ”
SIGN CHANGES TO AND ALL THE STATEMENTS INSIDE for LOOP ARE MINIMIZED
WE HAVE WRITTEN THE CODE NOW WE WANT TO COMPILE IT ( )
CLICK 1
( ) CLICK 2
COMPILATION IN PROGRESS
“RAM AND ROM PERCENTAGE INDICATE HOW MUCH RAM OR ROM OF MICROCONTROLLER THE WRITTEN CODE WILL USE” “ ” ,
:
.
“ ”
“ ” “ ( )”
THE C STATEMENT output_D 0 IS CONVERTED TO FOUR ASSEMBLY STATEMENTS
“ ” “ ” ( ). - “ ”
SOURCE FILE COF FILE HEX FILE (
COLLEGE OF AERONAUTICAL ENGEENERING CAE
INTRODUCTION
•
Pic wizard is a useful tool that helps the user
for initializing peripherals and writing code
for PIC u-Controller.
•
•
Different peripherals options/settings are
presented in form of Graphical User Interface
(GUI).
•
•
It creates the basic layout of the code that
include different interrupt service routines,
initialization parameters for timers,
interrupts and other device peripherals etc
.
•
•
•
( ) CLICK 1
( ) CLICK 2
WIZARD WINDOW
FEATURES WINDOW
( ) GENERAL 1
SELECT DEVICE
:
OSCILLATOR
- /
( ) CLICK 1
-USER WANTS TO USE RS 232
( ) CLICK 1
TIMER 1 DISABLED
. . .
TIMER 0 WITH 2 us Resol AND 51 2 us OVERFLOW TIME
TIMER 1 ENABLED
TIMER 1 SETTINGS
:
EACH TIMER SETTINGS GENERATES A CODE THAT WILL BE ADDED TO SOURCE FILE AT THE END OF WIZARD ( )
( ) CLICK 1
/
SELECT A D CONVERTERS
- ( - )
( ) CLICK 1
( ) CLICK 1
( ). . AS WE HAVE SELECTED EXTERNAL INTERRUPT PREVIOUS PAGE THIS CODE WILL BE ADDED TO SOURCE FILE
“ ” IF THERE ARE NO MORE FEATURES THAT USER WANT TO USE CLICK OK
/ & / . INITILIZATION CODE GENERATED BY WIZARD TO SET REQUIRED PARAMETERS OF TIMER INTERRUPT A D CONVERTER etc
(
, , - , / & … HEADER FILE HAS INFORMATION ABOUT THE SELECTED DEVICE CLOCK RS 232 PINS A D CONVERTERS FUSES etc ( )
CLICK 1
( ) CLICK 2
“
“prog1.h” IS HEADER FILE.
:
CCS PICC
DEVICE
INTRODUCTION
•
A large PIC family provides user, the flexibility
to select the chip which fulfill the
requirement optimally.
•
•
The devices which have large features are
more costly. So, from Economical point of
view, select the device which
only
has
those features that the design requires.
•
•
Device Selection Tool
is helpful in selecting
the appropriate chip which meets the
( ) CLICK 1
( ) CLICK 2
“SELECTED” SHOWS THE CHIPS WHICH FULFILL THE CRITERIA
“CRITERIA CONSISTS OF THE MINIUM FEATURES THE CHIP SHOULD HAVE”
. SPECIFY THE PIC FAMILY THE SELECTED CHIP SHOULD BELONG
, “ ’ ” “ ” IF WE REQUIRE USB PORT SO WE CHANGE Don t Care TO Yes
. ( )
Min 256 Byte RAM AND 8 KB ROM 8192 Bytes IS REQUIRED
- /
“ ” . . .
( ) CLICK 1
& .
FUSES AND INTERRUPTS
LIST
•
This tool of the compiler can be used
to see the fuses and interrupts that
can be used for a
specific device
.
•
•
Thus, it provides a quick glance, at
the fuses and interrupts options
available for a particular Pic device,
instead of tedious search in the
( ) CLICK 1
( ) CLICK 2
( . . ) SELECT DEVICE e g 16F877
( ) ALL THESE FUSES CAN BE USED FOR SELECTED DEVICE 16F877
( ) CLICK 1
SELECT DEVICE
SERIL PORT MONITER
This tool works same as hyper terminal
but in new windows (vista and later)
there is no hyper terminal so this tool
can be used to send/receive data
( ) CLICK 1
( ) CLICK 2
SELECT COM PORT
TYPE DATA TO SEND TO SERIAL PORT RECEIVED DATA APPEAR HERE
END
Don't blame the unfavorable circumstances that stops you from "
doing what needs to be done as the key lies in our decision not "