Saturday, June 23, 2012

PIC16 MCU Configuration For Programming

PIC16 MCU Configuration For Programming

Power-up Timer

Clock oscillator types:
● Watchdog, power-up, brown-out timers
● Low-voltage programming
● Code protection
● In-circuit debug mode

When programming the PIC microcontroller, certain operational modes must be set prior to the main program download. These are controlled by individual bits in a special configuration register separated from the main memory block. The main options are as follows.
Pic Programming C


Clock Options: In Pic 16
The ‘ 877 chip has two main clock modes, CR and XT. The CR mode needs a simple
capacitor and resistor circuit attached to CLKIN, whose time constant (C X R)
determines the clock period. R should be between 3 k and 100 k, and C greater than 20 pF. For example, if R=10 kΩ and C=10 nF, the clock period will be around 2 X C X R=200 μ s (calculated from the CR rise/fall time) and the frequency about 5 kHz. This option is acceptable when the program timing is not critical.

The XT mode is the one most commonly used, since the extra component cost is small compared with the cost of the chip itself and accurate timing is often a necessity. An external crystal and two capacitors are fitted to CLKIN and CLKOUT pins. The crystal frequency in this mode can be from 200 kHz to 4 MHz and is typically accurate to better than 50 ppm (parts per million) or 0.005%. A convenient value is 4 Mz, as this is the maximum frequency possible with a standard crystal and gives an instruction execution time of 1.000 μ s (1 million instructions per second, or 1 Mip).

A low-speed crystal can be used to reduce power consumption, which is proportional to
clock speed in CMOS devices. The LP (low-power) mode supports the clock frequency
range 32–200 kHz. To achieve the maximum clock speed of 20 MHz, a high-speed (HS)
crystal is needed, with a corresponding increase in power consumption. The MCU configuration fuses must be set to the required clock mode when the chip is programmed. Many PIC chips now have an internal oscillator, which needs no external components. It is more accurate than the RC clock but less accurate than a crystal. It typically runs at 8 MHz and can be calibrated in the chip configuration phase to provide a more accurate timing source.

Configuration Options

Apart from the clock options, several other hardware options must be selected. Watchdog Timer When enabled, the watchdog timer (WDT) automatically resets the processor after a given period (default 18 ms). This allows, for example, an application to escape from an endless loop caused by a program bug or run-time condition not anticipated by the software designer. To maintain normal operation, the WDT must be disabled or reset within the program loop before the set time-out period has expired. It is therefore important to set the MCU configuration bits to disable the WDT if it is not intended to use this feature. Otherwise, the program is liable to misbehave, due to random resetting of the MCU.

Power-up Timer
Oscillator Start-up Timer
Brown-out Reset (BoR)
Code Protection (CP)
In-Circuit Programming and Debugging
Low-Voltage Programming Mode
Electrically Erasable Programmable Read Only Memory

No comments:

Post a Comment