Podcast
Questions and Answers
What does the directive #include 18F452.H accomplish in a CCS C program?
What does the directive #include 18F452.H accomplish in a CCS C program?
What is the purpose of the #fuses directive in CCS C?
What is the purpose of the #fuses directive in CCS C?
Which fuse setting would enable the watchdog timer in a CCS C program?
Which fuse setting would enable the watchdog timer in a CCS C program?
What function should be used to create a delay of microseconds in CCS C?
What function should be used to create a delay of microseconds in CCS C?
Signup and view all the answers
Why does CCS C need to know the clock frequency when generating delays?
Why does CCS C need to know the clock frequency when generating delays?
Signup and view all the answers
What is a drawback of including library files multiple times in CCS C programs?
What is a drawback of including library files multiple times in CCS C programs?
Signup and view all the answers
What is incorrect about specifying the fuse setting NOBROWNOUT?
What is incorrect about specifying the fuse setting NOBROWNOUT?
Signup and view all the answers
Which statement about CCS C's handling of source files is true?
Which statement about CCS C's handling of source files is true?
Signup and view all the answers
Study Notes
Device Definition File
- A CCS C program begins with pre-processor directives like
#include
,#fuses
, and#use delay
. - The directive
#include
includes the system header file18F452.H
, which is essential for specifying the Special Function Registers (SFRs). - This device-specific file also holds the values to be written to these registers.
Fuses
- The
#fuses
directive allows configuration of the PIC microcontroller's fuse settings. - Example settings explained:
- HS: High-speed crystal or resonator used for the clock.
- NOWDT: Disables the watchdog timer, preventing it from resetting the PIC unexpectedly.
- NOBROWNOUT: Deactivates the brown-out detector, which protects the microcontroller from low voltage conditions.
- NOPROTECT: Disables code protection, allowing the code to be read from memory.
- PUT: Enables the power-on timer function.
Delays
- Delay functions in CCS C include
delay_us()
anddelay_ms()
, which introduce delays measured in microseconds and milliseconds respectively. - These functions rely on the clock frequency to calculate the appropriate number of machine cycles for accurate timing.
- The directive
#use delay(clock=20000000)
defines a clock frequency of 20 MHz for the PIC microcontroller.
Multiple Source Code Files
- CCS C does not facilitate separate compilation and linking of different source code files.
- To enhance code organization and reuse, commonly-used library functions can be stored in separate files.
- The directive
#include "lcd.c"
incorporates thelcd.c
library file into the current file, ensuring that it is available during compilation. - Although this method of including library files can be less efficient due to repeated compilation, typical compilation times for PIC programs remain short, usually just a few seconds.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
This quiz covers the basics of CCS C programming, focusing on device definition files and directives. It includes information about pre-processor directives, fuse settings, and how to include necessary libraries for programming specific microcontrollers. Test your knowledge on how to properly set up your programming environment!