CCS C Programming Basics
8 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What does the directive #include 18F452.H accomplish in a CCS C program?

  • It includes device-specific definitions. (correct)
  • It prevents code optimization.
  • It adds delays to the program.
  • It specifies the clock frequency.

What is the purpose of the #fuses directive in CCS C?

  • To enable high-speed clock settings.
  • To specify the configuration states for the PIC. (correct)
  • To include external libraries.
  • To define macro functions.

Which fuse setting would enable the watchdog timer in a CCS C program?

  • NOWDT
  • NOPROTECT
  • WDT (correct)
  • NOBROWNOUT

What function should be used to create a delay of microseconds in CCS C?

<p>delay_us() (B)</p> Signup and view all the answers

Why does CCS C need to know the clock frequency when generating delays?

<p>To accurately calculate machine cycles. (A)</p> Signup and view all the answers

What is a drawback of including library files multiple times in CCS C programs?

<p>It can lead to unnecessary compilation time. (A)</p> Signup and view all the answers

What is incorrect about specifying the fuse setting NOBROWNOUT?

<p>It enables the brown-out detector. (D)</p> Signup and view all the answers

Which statement about CCS C's handling of source files is true?

<p>It compiles all source files every time. (C)</p> 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 file 18F452.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() and delay_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 the lcd.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.

Quiz Team

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!

More Like This

CCS Chapter 3 Flashcards
10 questions

CCS Chapter 3 Flashcards

EffortlessGyrolite7402 avatar
EffortlessGyrolite7402
CCS C Programming and Features
0 questions
CCS 104: Single-Dimension Array
13 questions
Use Quizgecko on...
Browser
Browser