PIC Development Systems:PIC 16F690 Chip

PIC 16F690 Chip

The data sheet for this chip should be downloaded from www.microchip.com and studied in conjunction with this section. The pin-out can be seen in the schematic Figure 7.3; it has only 20 pins in total, hence the ‘low pin count’ description. The 16F690 is representative of the 16 series chips as it has a typical range of interfaces, including:

• Digital input/output

• Analogue inputs (12)

• Multi-mode timers (3)

• Serial ports (USART, SPI, I2C)

• An internal clock oscillator (4 MHz).

The chip has 4k of program memory, with 256 bytes each of random access memory (RAM) and electrically erasable programmable read-only memory (EEPROM). It can be initialized to provide simple digital input/output (I/O) on 18 of the 20 pins, which are grouped as ports A (6), B (4) and C (8). Notice that port bits RB0 to RB3 are missing, and the chip is programmed via RA0 and RA1. In common with most current chips, the 16F690 has analogue inputs, which allow voltage measurement interfaces to be connected. The basic setup will be explained here, and there is further information on the principles of analogue to digital conversion in Section 12.3.3 (Chapter 12). For digital I/O the ports must be initialized as shown in the test program below because the analogue pins default to analogue inputs if not explicitly set up.

The analogue inputs use a single analogue to digital (A/D) converter, which can be connected to any one of 12 input pins (AN0 to AN11) via a multiplexer. The A/D converts an input voltage to a corresponding 10-bit binary code, which is placed automatically in special function registers (SFRs) ADRESH and ADRESL when the conversion is finished. The conversion is triggered by setting bit ADCON0,1 (A/D control register 0) and is complete when the same bit is set low by the hardware. This bit can be polled (checked repeatedly in a loop) or an interrupt set to indicate completion.

An alternative method of checking an analogue input is to use a comparator, which simply indicates which of two inputs is at a higher voltage (the input polarity). The analogue comparator has two inputs, labeled plus (þ) and minus (-). Signals are applied to both, and the output goes logic high if the voltage at the (þ) input is higher than at the (-) input, otherwise it is low. In the 16F690, several inputs are multiplexed with reference voltages so different combinations of inputs can be detected (see data sheet).

The hardware timers can be used in the usual counter or timer mode, but in addition can be used in capture, compare or pulse width modulation (PWM) mode. Capture means the timer value is stored when a selected input changes, allowing, for example, the period of an input to be measured. Compare mode is the inverse operation: the timer value is compared after each increment to a reference register and an output changed or interrupt generated when they match. This can be used to generate an output pulse waveform of a set period. PWM is similar, designed to provide a pulse waveform with a set mark/space (high/low) ratio.

Serial ports allow communication with other devices (microprocessors or computers) via single- or two-wire connection. There are various methods (protocols) available; the 16F690 supports RS232, RS485, LIN, SPI and I2C. The function of each pin must be selected during

initialization, since each has multiple operating modes. The internal clock frequency is selected in the OSCCON register. The internal clock defaults to a frequency of 4 MHz, with 8 MHz the maximum. The default is accepted in the test program.

All the peripheral interfaces mentioned here are explained further in Chapter 12, and typical applications are described in detail in Interfacing PIC Microcontrollers: Embedded Design by Interactive Simulation (Newnes 2006) by this author.

Leave a comment

Your email address will not be published. Required fields are marked *