Skip to main content

Posts

Showing posts from December, 2016

Familiarize with 8051 Architecture

Program Counter and Data Pointer The 8051 contains two 16-bit registers-the program counter(PC) and data pointer(DPTR). Each is used to hold the address of a byte in memory. Program instruction bytes are fetched from locations in memory that are addressed by PC. Program ROM may be on the chip at address 000h to 0FFFh, external to the chip for addresses from 0000h to FFFFh. The PC is automatically incremented after every instruction bytes is fetched and may also be altered by certain instructions. The PC is the only register that does not have an external address. The DPTR register is made up of two 8-bit registers named DPH and DPL which are used to furnish memory address for internal and external code access. The DPTR is under control of program instructions and can be specified by its 16-bit name DPTRor by each individual byte name, DPH and DPL. DPTR does not have a single internal address: DPL and DPH are each assigned an address. A and B CPU registers The 8051 contains 34

ATMEGA-32 Pin-out Diagram

Overview The Atmel®AVR®ATmega32 is a low-power CMOS 8-bit microcontroller based on the AVR enhanced RISC architecture. By executing powerful instructions in a single clock cycle, the ATmega32 achieves throughputs approaching 1 MIPS per MHz allowing the system designer to optimize power consumption versus processing speed. AVR spin-out diagrams Block diagram:- The Atmel®AVR®AVR core combines a rich instruction set with 32 general purpose working registers. All the 32 registers are directly connected to the Arithmetic Logic Unit (ALU), allowing two independent registers to be accessed in one single instruction executed in one clock cycle. The resulting architecture is more code efficient while achieving throughputs up to ten times faster than conventional CISC microcontrollers. The ATmega32 provides the following features: 32Kbytes of In-System Programmable Flash Program memory with Read-While-Write capabilities, 1024bytes EEPROM, 2Kbyte SRAM, 32 general purpose I/O line

AVR Microcontrollers

AVR is a microcontroller belonging to the family of Reduced Instruction Set Computer(RISC). In RISC architecture the instruction set of the computer are not only fewer in number but also simpler and faster in in operation. AVR was developed in year 1996 by Atmel corporation. The architecture of AVR was developed by Alf-Egil Bogen and Regards Swollen. AVR derives from its developers and stands for A lf-Egil Bogen V egard Wollen R ISC microcontroller, also known as A dvanced V irtual R ISC machine. The AT90S8515 was first microcontroller which was based on AVR architecture. However the first microcontroller to hit the commercial market was AT90S1200 in the year 1997. AVR microcontrollers are available in three categories as shown below; Series Name Pins Flash Memory Special Features Tiny AVR 6-32 0.5-8Kb Small in size Mega AVR 28-100 4-256Kb Extended peripherals XmegaAVR AVR 44-100 16-384Kb DMA,Event system included TinyAVR:- Less memory, small size, suita

8051 Keyboard Interfacing

Keyboards are organized in a matrix of rows and columns. The CPU accesses both rows and columns through ports. Therefore, with two 8-bit ports, an 8 x 8 matrix of keys can be connected to a microprocessor. When a key is pressed, a row and a column make a contact. Otherwise, there is no connection between rows and columns. In IBM PC keyboards, a single microcontroller takes care of hardware and software interfacing. A 4x4 matrix connected to two ports. The rows are connected to an output port and the columns are connected to an input port. Grounding Rows and reading Columns:- 8051 keyboard interfacing It is the function of the microcontroller to scan the keyboard continuously to detect and identify the key pressed. To detect a pressed key, the microcontroller grounds all rows by providing 0 to the output latch, then it reads the columns. If the data read from columns is D3 – D0 =1111, no key has been pressed and the process continues till key press is detected. If one of t

Microcontroller survey

Markets for microcontrollers can run into millions of applications. At these volume the microcontroller is a commodity item and must be optimized so that cost is at minimum. Semiconductor manufacturers have a mind-numbing array of designs that would seem to meet almost any need. Some of the chips listed in this post are no longer in regular production, most are current, and a few are best termed "smokeaware": the dreams of the aggressive marketing department. 4-bit Microcontrollers:- In a commodity chip, expense is represented more by the volume of package and number of pins. To minimize the pin count and package size, it is necessary that the basic data word-bit count be held to a minimum, still enabling useful intelligence to be implemented. Although 4-bits, in this era of 64-bit "maximicros" may seems somewhat ludicrous, one must recall that original 4004 microprocessor was a 8-bit device, and all else followed. Indeed in terms of production numbers, 4-bi

I/O Port Programming Using Embedded C

1.Sending 00H to FFH to Ports #include <reg51.h> void main(void) { unsigned char z; for (z=0;z<=255;z++) P1=z; } Caution 1. Pay careful attention to  the size of the data. 2. Try to use unsigned char instead of int if possible. 2.Sending ASCII Characters to Ports Statement: Write an 8051 C program to send hex values for ASCII characters of  0, 1, 2, 3, 4, 5, A, B, C, and D to port P1. Program #include <reg51.h> void main(void) { unsigned char mynum[]=“012345ABCD”; unsigned char z; for (z=0;z<=10;z++) P1=mynum[z]; } 3.Toggle Port Bits Write an 8051 C program to toggle all the bits of P1 continuously. Solution: //Toggle P1 forever #include <reg51.h> void main(void) { for (;;) { p1=0x55; p1=0xAA; } } 4.Sending values to Port Write an 8051 C program to send values of –4 to +4 to port P1. Solution: //Singed numbers #include <reg51.h> void main(void) { char mynum[]={+1,-1,+2,-2,+3,-3,+4,-4}

Hex file generation using Keil

Keil Î¼vision is an Integrated Development Tool(IDE) to write, simulate and flash our program written either in assembly language or in C. We can also flash our program to mcs51 series(8051 family) microcontroller using Keil Î¼vision IDE. But I will prefer you to use Flashmagic developed by NXP to flash your program into 89c51(I am emphasize that 8051 has no flash memory. But we can use other microcontrollers that are code compatible with 8051 like 89c51 from Atmel or 89c51RD2BN from NXP etc.). But we want to familiar with Keil Î¼vision to generate hex files from our embedded C programs. You want to click here to download latest version of Keil Î¼vision. This will redirect you to official website of Keil. You must fill the form before download Keil. The Keil Î¼vision IDE setup file has more than 100 Mb in size. After downloading this setup file double click on it and install it. During installation this may ask your e-mail ID and lot of things. If you want notifications about new updat

Introduction to 8051 embedded C

For 8051 we need to include the file reg51.h. This file contains the all the definitions of 8051 registers. With this information C compiler produces hex file that can be downloaded into the ROM of the microcontroller. It is important to note that the size of the hex file produced by the assembly language is much larger than the hex file produced by C compiler. Apart from this fact, there is many reasons for writing programs in C instead of assembly: ●It is much easier and less time consuming to write programs in C assembly. ●C is more flexible; it is easier to modify and update. ●Programming in C allows to use code available in function libraries. ●Program written inC for one microcontroller is portable to other microcontrollers with little or no modifications. Data Types in 8051 Embedded C The table shown below lists the data types that are available in typical C51 compiler. The gives information about the size of the data variable and it's value range. Data type

Pin Description of 8051

The 8051 packaged in a 40-pin DIP. The figure shows the pin diagram of 8051. Many of the pins of 8051 are used for more than one function. The alternative functions are also shown in the diagram. The 8051 has 32 I/O pins configured as four eight-bit parallel ports(P0, P1, P2 and P3). All four ports are bidirectional i.e., each pins will be configured as input or output(or both). All port-pins are multiplexed except pins of port 1. Each ports consist of a latch, an output driver and an input buffer. Port 0(Pins 32-39): Port 0 pins are used as I/O pins. The output drives and input buffer of port 0 are used to access external memory address, time multiplexed with the data being written or read. Thus, port 0 can be used as a multiplexed address{/data bus. Port 1(Pins 1-8): Port 1 pins can used only as I/O pins Port 2(Pins 21-28): The output drives of port 2are used to access external memory. Port 2 outputs are high order byte of the external memory address when the address is 16

8051: Unique Features

The 8051 microcontroller is generic part number actually includes a whole family of microcontrollers that have numbers ranging from 8031 to 8751 and are available in N-channel Metal Oxide Silicon(NMOS) and Complimentary Metal Oxide Silicon(CMOS) constructed in a variety of package types. The unique features of 8051 are;   ♂Internal RAM and ROM   ♂I/O ports with programmable pins   ♂Timers and counters   ♂Serial data communication The block diagram shows usual CPU components- program counter, ALU,  working registers, and clock circuits. The 8051 architecture consists of these specific features; ●8-bit CPU registers A(the accumulator) and B ●16-bit program counter(PC)and data pointer(DPTR) ●8-bit status word ●Internal ROM or EPROM(for 8751) of 0(for 8031) to 4K(for 8051) ●Internal RAM of 128 bytes:   ◆Four register banks each containing 8 registers   ◆16-bytes, which may be addressed at the level   ◆80-bytes general purpose data memory   ◆32 I/O pins arranged as 4 eight

8051 Simple Programs

Sum of 8-bit Numbers Stored in Memory Here  we will discuss about 8051 programs but we can't discuss about all of the 8051 instructions. For programming 8051 we should know about assembler directives as well as instruction set. Click  here to download Atmel c51 user guide that will discuss about 8051(c51 family microcontroller) instruction set, assembler directives, c51 cross assembler from Atmel.  Program ORG 00H MOV R0,#50H   ; get memory location in memory pointer R0 MOV R1,#51H   ; get memory location on memory pointer register R1 MOV A,@R0       ; get content of memory location 50H to accumulator ADD A,@R1        ; add content of A with content of memory location 51H and store result in A MOV R0,#52H    ; get 52H to memory pointer R0 MOV@R0,A         ; copy content of A to memory location 52H END Add 16-bit Numbers Program ORG 00H MOV DPTR,#2040H   ; get 2040H into DPTR MOV A,#2BH              ; get lower byte of second 16-bit number on accumulator MO