2 Basics of C Flashcards
The structure that both ASM and C share?
- Configuration bits
- Variable storage
- Entry Point
- Ininite loop
STRUC: What are the configuration bits?
These configure the basic setup of the PIC including things like the oscillator type and the presence of the watch dog timer
STRUC: What is variable storage setup?
Definitions of variables, including where in memory to store them
STRUC: Entry point
An indicator of where in the code the program counter will start
STRUC: Infinite loop?
An infinite loop is commonly used to keep repeating a set of operations ad infinitum
Config(Role/Default): FOSC?
The type of oscillator to use (external/internal/crystal)
Default: XT(external crystal)
Config(Role/Defult): WDTE?
Enable/Disable the watch dog timer
OFF(no wdt)
Config(Role/Defult): PWRITE?
Enable/Disable the power-up timer (72 ms)
ON(power-up timer)
Config(Role/Defult): CP?
Enable/Disable code protection
OFF(code protection)
Configuration bits for LED flash?
pragma config FOSC = XT // XT oscillator
// Setup configuration bits
Configure oscillator frequency for flashing LED?
define _XTAL_FREQ 4000000
// Oscillator Frequency (4 MHz)
Flashing LED: Code to import library functions?
include
// Include C library functions for PIC
Flashing LED: Code to write to ports?
PORTBbits.RB0 = 1; // Set RB0 high __delay_ms(500); // Wait 0.5 seconds PORTBbits.RB0 = 0; // Set RB0 low __delay_ms(500); // Wait 0.5 seconds
Flashing LED: Port Setup?
// Set all port B bits to be output
TRISB = 0x0;
Flashing LED: Main loop for the program?