• No results found

PIC Microcontroller Features (Explained)

watchdog timer is used to detect a system problem, such as the program being in an endless loop. A watchdog is a safety feature that prevents runaway software and stops the microcontroller from executing meaningless and unwanted code. Watchdog facilities are commonly used in real-time systems where it is required to regularly check the successful termination of one or more activities.

1.3.5 Reset input

A reset input is used to reset a microcontroller. Resetting puts the microcontroller into a known state such that the program execution starts from address 0 of the program memory. An external reset action is usually achieved by connecting a push-button switch to the reset input such that the microcontroller can be reset when the switch is pressed.

1.3.6 Interrupts

Interrupts are very important concepts in microcontrollers. An interrupt causes the microcon- troller to respond to external and internal (e.g. a timer) events very quickly. When an interrupt occurs the microcontroller leaves its normal flow of program execution and jumps to a special part of the program, known as the Interrupt Service Routine (ISR). The program code inside the ISR is executed and upon return from the ISR the program resumes its normal flow of execution. The ISR starts from a fixed address of the program memory. This address is also known as the

interrupt vector address. For example, in a PIC16F84 microcontroller the ISR starting address is

4 in the program memory. Some microcontrollers with multi-interrupt features have just one interrupt vector address, while some others have unique interrupt vector addresses, one for each interrupt source. Interrupts can be nested such that a new interrupt can suspend the execution of another interrupt. Another important feature of a microcontroller with multi-interrupt capability is that different interrupt sources can be given different levels of priority.

1.3.7 Brown-out detector

Brown-out detectors are also common in many microcontrollers and they reset a microcontroller if the supply voltage falls below a nominal value. Brown-out detectors are safety features and they can be employed to prevent unpredictable operation at low voltages, especially to protect the con- tents of EEPROM-type memories.

8 PIC BASIC projects

The A/D conversion process must be started by the user program and it may take several hundreds of microseconds for a conversion to complete. A/D converters usually generate interrupts when a conversion is complete so that the user program can read the converted data quickly.

A/D converters are very useful in control and monitoring applications since most sensors (e.g. temperature sensor, pressure sensor, force sensor, etc.) produce analogue output voltages.

1.3.9 Serial I/O

Serial communication (also called RS232 communication) enables a microcontroller to be con- nected to another microcontroller or to a PC using a serial cable. Some microcontrollers have built-in hardware called USART (Universal Synchronous–Asynchronous Receiver–Transmitter) to implement a serial communication interface. The baud rate and the data format can usually be selected by the user program. If any serial I/O hardware is not provided, it is easy to develop soft- ware to implement serial data communication using any I/O pin of a microcontroller. We shall see in Chapter 4 how to use the PicBasic and PicBasic Pro statements to send and receive serial data from any pin of a PIC microcontroller.

Some microcontrollers incorporate SPI (Serial Peripheral Interface) or I2C (Integrated Inter

Connect) hardware bus interfaces. These enable a microcontroller to interface to other compatible devices easily.

1.3.10 EEPROM data memory

EEPROM type data memory is also very common in many microcontrollers. The advantage of an EEPROM memory is that the programmer can store non-volatile data in such a memory, and can also change this data whenever required. For example, in a temperature monitoring application the maximum and the minimum temperature readings can be stored in an EEPROM memory. Then, if the power supply is removed for whatever reason, the values of the latest readings will still be available in the EEPROM memory.

PicBasic and PicBasic Pro languages provide special instructions for reading and writing to the EEPROM memory of a microcontroller which has such memory built-in.

Some microcontrollers have no built-in EEPROM memory, some provide only 16 bytes of EEPROM memory, while some others may have as much as 256 bytes of EEPROM memories.

1.3.11 LCD drivers

LCD drivers enable a microcontroller to be connected to an external LCD display directly. These drivers are not common since most of the functions provided by them can be implemented in software.

Microcontroller systems 9

1.3.12 Analogue comparator

Analogue comparators are used where it is required to compare two analogue voltages. Although these circuits are implemented in most high-end PIC microcontrollers they are not common in other microcontrollers.

1.3.13 Real-time clock

Real-time clock enables a microcontroller to have absolute date and time information continu- ously. Built-in real-time clocks are not common in most microcontrollers since they can easily be implemented by either using a dedicated real-time clock chip, or by writing a program.

1.3.14 Sleep mode

Some microcontrollers (e.g. PIC) offer built-in sleep modes where executing this instruction puts the microcontroller into a mode where the internal oscillator is stopped and the power consump- tion is reduced to an extremely low level. The main reason of using the sleep mode is to conserve the battery power when the microcontroller is not doing anything useful. The microcontroller usu- ally wakes up from the sleep mode by external reset or by a watchdog time-out.

1.3.15 Power-on reset

Some microcontrollers (e.g. PIC) have built-in power-on reset circuits which keep the microcon- troller in reset state until all the internal circuitry has been initialised. This feature is very useful as it starts the microcontroller from a known state on power-up. An external reset can also be pro- vided where the microcontroller can be reset when an external button is pressed.

1.3.16 Low power operation

Low power operation is especially important in portable applications where the microcontroller- based equipment is operated from batteries. Some microcontrollers (e.g. PIC) can operate with less than 2 mA with 5 V supply, and around 15A at 3 V supply. Some other microcontrollers, especially microprocessor-based systems where there could be several chips may consume sev- eral hundred milliamperes or even more.

10 PIC BASIC projects

Related documents