‘ Read Only Memory (ROM) is a type of memory used to save the program forever. If you want to write a program it depends on the size of the memory. ROM can be built in the microcontroller or can be easily added as an external chip, but depends on the kind of the microcontroller. It has some disadvantages. If ROM is added as an external chip, the microcontroller is low-priced and the program can be longer. The internal ROM is frequently smaller and more expensive.
‘ Random Access Memory (RAM) is the best known form of computer memory. RAM is considered “random access” because you can access any memory cell directly if you know the row and column that intersect at that cell
‘ The EEPROM is a special type of memory not in all microcontrollers. Plus it’s a read only memory. Its contents may be changed during program execution but remains permanently saved. It is often used to store values, which must be saved after turning the power supply off. A disadvantage of this memory is that the process of programming is relatively slow. It is measured in milliseconds.
‘ Program Counter is to hold the current address of the instruction that is being executed and to hold the address of the instruction that will be executed next.
1. Instruction decoder is a part of the electronics which recognizes program instructions and runs other circuits. The abilities of this circuit are said in the “instruction set” which is different for each microcontroller family.
2. Arithmetical Logical Unit (ALU) performs all mathematical and logical operations upon data.
3. Accumulator is an SFR closely related to the operation of ALU. It is a kind of working desk used for storing all data upon which some operations should be executed. It also stores the results ready for use in further processing.
‘ Timer/Counters: Most programs use these tiny electronic stopwatches in their operation. These are commonly 8 or 16-bit SFRs the contents of which is automatically incremented by each coming pulse. Once the register is completely loaded an interrupt is generated. If these registers use an internal quartz oscillator as a clock source, then it is possible to measure the time between two events. Then such a timer is turned into a counter.
‘ I/O pins: One of the most important features of a microcontroller is its I/O pins, which enable the microcontroller to communicate with the outside world. Although some microcontrollers have separate input pins and output pins, most have shared I/O pins that can be used for both input and output.
‘ Clock: The CPU and other components of the microcontroller are driven by a clock that provides timing pulses that control the pacing of program instructions as they are executed one at a time by the CPU. For most microcontrollers, the clock ticks along at a pace of a few million ticks per second.
In contrast, the clock that drives a typical desktop computer ticks along at a few billion ticks per second
Microcontrollers are useful to the extent that they communicate with other devices, such as sensors, motors, switches, keypads, displays, memory and even other micro-controllers.
Many microcontroller designs typically mix multiple interfacing methods. In a very basic form, a microcontroller system can be viewed as a system that reads from inputs, performs processing and writes to outputs.
Up to three memory types on PIC16F84A
1. Program Memory – instructions
2. Data Memory – variable data values
3. Data EEPROM Memory – non-volatile data storage
The first memory type is common to ALL microcontrollers. This is called Program
Memory and its purpose is to store instructions.
The second memory type Data Memory contains the Special Function Registers and
General Purpose RAM. The Special Function registers are commonly referred to as
SFRs and consist of the configuration, control and status registers for peripheral and
Port I/O. General Purpose RAM, commonly referred to as GPR, is the area that the
application firmware uses to store and use data.
In addition to Program Memory and Data Memory, some microcontrollers also
contain the third memory type, Data EEPROM Memory. The Data EEPROM
Memory area of a microcontroller provides non-volatile data memory storage that
can be rewritten many times.
The architectural model which PIC16F84 microcontroller uses is Harvard. The Harvard architecture is known as computer architecture. Harvard architecture main job is to find out how memory is organized and how it communicates with the cpu as well as determining the performance of a device. Harvard is linked to the PIC16F84 as it can use different types of memories to store data and instructions. The program memory has its own instruction bus and its own control bus. The data memory is independent from the program memory as it has its own address bus, data bus and control bus, however, the program memory can only be read when data memory can be read and written
Special Microcontroller Features:
‘ 10,000 erase/write cycles Enhanced FLASH
‘ Program memory typical 10,000,000 typical erase/write cycles EEPROM
‘ Data memory typical
‘ EEPROM Data Retention > 40 years
‘ In-Circuit Serial Programming’ (ICSP’) – via two pins
‘ Power-on Reset (POR), Power-up Timer (PWRT),
‘ Oscillator Start-up Timer (OST)
‘ Watchdog Timer (WDT) with its own On-Chip RC
‘ Oscillator for reliable operation
‘ Code protection
‘ Power saving SLEEP mode
‘ Selectable oscillator options
PORTA and TRISA Registers
PORTA is a 5-bit wide port. The corresponding data direction register is TRISA. Setting a TRISA bit will make the corresponding PORTA pin an input. Clearing a TRISA bit will make the corresponding PORTA pin an output.
Reading the PORTA register reads the status of the pins, whereas writing to it will write to the port latch. All write operations are read modify write operations. Therefore a write to a port indicates that the port pins are read. This value is modified and then written to the port data latch.
PORTB and TRISB Registers
PORTB is an 8-bit wide port. The corresponding data direction register is TRISB. Setting a TRISB bit will make the corresponding PORTB pin an input. Clearing a TRISB bit will make the corresponding PORTB pin an output.
Each PIC16CF84A instruction is a 14-bit word, divided into an OPCODE which specifies the instruction type and one or more operands which further specify the operation of the instruction. The PIC16CF84A instruction set summary in Table 7-2 lists byte-oriented, bit-oriented, and literal and control operations.
All instructions are executed within one single instruction cycle, unless a conditional test is true or the program counter is changed as a result of an instruction. In this case, the execution takes two instruction cycles with the second cycle executed as a NOP. One instruction cycle consists of four oscillator periods. If a conditional test is true or the program counter is changed as a result of an instruction the instruction execution time is 2 us.
There are two memory blocks in the PIC16F84A. These are the program memory and the data memory. Each block has its own bus so that access to each block can occur during the same oscillator cycle. The data memory can further be broken down into the general purpose RAM and the Special Function Registers. The data memory area also contains the data EEPROM memory. This memory is not directly mapped into the data memory but is indirectly mapped. That is an indirect address pointer requires the address of the data EEPROM memory to read/write.
The PIC16CF84A has a 13-bit program counter addressing a program memory space. For the PIC16F84A, the first 1K x 14 (0000h-03FFh) are physically implemented. For example, for locations 20h, 420h, 820h, C20h, 1020h, 1420h, 1820h, and 1C20h, the instruction will be the same. The RESET vector is at 0000h and the interrupt vector is at 0004h.
The data memory is separated into two areas. The first is the Special Function Registers (SFR) area, while the second is the General Purpose Registers (GPR) area. The SFRs control the operation of the device. Shares of data memory are banked. This is for both the SFR area and the GPR area. The GPR area is banked to allow greater than 116 bytes of general purpose RAM. The banked areas of the SFR are for the registers that control the peripheral functions. Banking requires the use of control bits for bank selection. These control bits are located in the STATUS Register.
...(download the rest of the essay above)