Showing posts with label Hardware. Show all posts
Showing posts with label Hardware. Show all posts

14 June 2010

Understanding Processor Architecture: Machine and Assembly Language

The processor understands only the machine language, whose instructions consist of strings of 1s and 0s. Machine language is closely related to the assembly language. We prefer to use the assembly language rather than the machine language. Programming in the assembly language also requires knowledge about the processor architecture.

Assembly language programming is referred to low-level programming because each assembly language instruction performs a much lower-level task compared to an instruction in a high-level language. Assembly language instructions are processor specification dependents. For example, a program written in the Intel assembly language cannot be executed on the PowerPC processor.

Here are some IA-32 assembly language examples:
inc result
mov class_size, 45
and mask1, 128
add marks, 10

The first instruction increments the variable result. This assembly language instruction is equivalent to

result++;

in C. The second instruction initializes class_size to 45. The equivalent statement in C is

class_size = 45;

The third instruction performs the bitwise and operation on mask1 and can be expressed in C as

mask1 = mask1 & 128;

The last instruction updates marks by adding 10. In C, this is equivalent to

marks = marks + 10;

We can translate the assembly language instructions to the equivalent machine language instructions. Machine language instructions are written in the hexadecimal number system. Here are some IA-32 machine language examples:


Assembly


Operation


Machine language (in hex)


nop

No operation90

inc result

IncrementFF060A00

mov class_size, 45

CopyC7060C002D00

and mask, 128

Logical and80260E0080

add marks, 10

Integer addition83060F000A


References

  • Guide to RISC Processors for Programmers and Engineers by Sivarama P. Dandamudi, Springer (2005), ISBN 0-387-21017-2.

19 April 2007

8051 mcu, von Neumann vs Harvard Architectures

We can classify computer architectures into two categories:

von Neumann architecture: computers has a single, common memory space in which both program instructions and data are stored. There is a single internal data bus that fetches both instructions and data. They can not be performed at the same time.

Harvard architecture: computers have separate memory areas for program instructions and data. There are two or more internal data buses, which allow simultaneous access to both instructions and data. The CPU fetches program instructions on the program memory bus.

The 8051 microcontrollers (MCS-51) have an 8-bit data bus. They can address 64K of external data memory and 64K of external program memory. These may be separate blocks of memory, so that up to 128K of memory can be attached to the microcontroller. Separate blocks of code and data memory are referred to as the Harvard architecture. A single block of memory may be mapped to act as both data and program memory. This is referred to as the Von Neumann architecture.

The 8051 has two separate read signals, RD# (P3.7) and PSEN#. The RD# (P3.7) is activated by clearing to logic level 0 when a byte is to be read from external data memory, PSEN#, from external program memory. All external code is fetched from external program memory. The bytes from external program memory may be read by special read instructions such as the MOVC. And there are separate instructions to read from external data memory, such as the MOVX instruction. In order to read from the same block using either the RD# signal or the PSEN# signal, the two signals are combined with a logic AND operation. This way, the output of the AND gate is low when either input is low.

By adopting the Von Neumann architecture, code may be written to memory as data bytes, and then executed as program instructions.

Further Reading

27 March 2007

Understanding Processor Architecture: Simplify Computer Complexity

Computers are complex systems. We study computer systems by using layers of abstraction. We use a hierarchical structure to simplify the management. Each level of management filters out unnecessary details on the lower levels and presents only an abstracted version to the higher-level management.

People can look at computer systems from several different perspectives depending on the type of their interaction. We use the concept of abstraction to look at only the details that are necessary from a particular viewpoint. For example, a computer user interacts with the system through an application program. Suppose you are interested in browsing the Internet. Your obvious choice is to interact with the system through a Web browser such as the Fire fox (FF) or Internet Explorer (IE). On the other hand, if you are a computer architect, you are interested in the internal details that do not interest a normal user of the system.

From the programmer’s viewpoint, there exists a hierarchy from low-level languages to high-level languages (see Figure 1). At the lowest level, we have the machine language that is the language understood by the machine hardware. Because digital computers use 0 and 1 as their alphabet, machine language naturally uses 1s and 0s to encode the instructions. One level up, there is the assembly language as shown in Figure 1. Assembly language does not use 1s and 0s; instead, it uses mnemonics to express the instructions. Assembly language is closely related to the machine language.

computer abstraction layersFigure 1. Abstract layers of Computer Systems

References

  • Guide to RISC Processors for Programmers and Engineers by Sivarama P. Dandamudi, Springer (2005), ISBN 0-387-21017-2.


26 January 2007

OpenServo

OpenServo is an open community-based project started by Mike Thompson with the goal of creating a low-cost digital servo for robotics. The hardware and software design of the OpenServo is free for anyone to use and modify to meet their particular needs. It is currently being developed by a small group of dedicated individuals striving to maintain the very best in free, open source software and standards. We hope that you will find the OpenServo project interesting and become a member of our community.

The OpenServo is a combination of hardware and software meant to replace the original PCB internal to low-cost analog RC servos such as the Futaba S3003 or HiTec HS-311


Some features of the OpenServo include:

  • High performance AVR 8-bit microcontroller

  • Compact H-Bridge implemented with low-cost MOSFET drivers

  • I2C/TWI based interface for control and feedback

  • Control over servo position and speed

  • Feedback of servo position, speed, voltage and power consumption

  • EEPROM storage of servo configuration information

  • Software written in C using free development tools

  • I2C/TWI based bootloader and Windows GUI programmer

  • Total cost about $20 per servo in quantity ($10 servo hardware + $10 parts)

Information can be found on this site regarding Hardware, Software and Tools & Utilities to create your own OpenServo.

Home page: http://openservo.com/

29 November 2006

128KB Flash 8051 MCU from Atmel

AT89C51RE2, an 8051 based microcontroller with 128kbyte of flash, has been launched from Atmel. The device is an addition to the existing 16-, 32- and 64Kbyte 8051 flash family of AT89C51RB2/RC2/RD2/ED2 MCUs. This new chip offers 8kbyte of ram, two UARTs, watchdog timer, power on reset, power fail detector and up to 50 general purpose I/Os. Suited to industrial and consumer applications, the AT89C51RE2 can operate from 2.7 to 5.5V and achieves a 4MIPS throughput when running at 40MHz.

A key feature is the on chip debug capability that enables low cost emulation. The hardware debug system with Windows IDE interface allows the user to access debugging functions built into the AT89C51RE2 resulting in faster development and verification of user code in real time.

The AT89C51RE2 is available in 44-pin PLCC and VQFP packages at $4.80 for 10,000 units.

Atmel offers the AT89STK-11, a starter kit for $99, to evaluate the AT89C51RE2; designers can either run the demonstration program or their own application. A new low-cost on-chip debug tool, AT89OCD-01 will be available by the end of November 2006.

Source: www.newelectronics.co.uk and www.eetasia.com

28 November 2006

Low-cost ARM7TDMI Evaluation Board based on STR730FZ2T6

Embest announced the availablity of the STDV730F, a low-cost development board based on STR730FZ2T6, ARM7TDMI 32-BIT processor from STMicroelectronics.

Features
  • 256 Kbytes of flash
  • 16 Kbytes of RAM
  • up to 16-channel 10-bit ADC
  • 20 timers
  • 4xUARTs
  • 3xCANs
  • SPI
  • I2C
  • DMA
  • RTC
  • PWM
  • 112 GPIO

The board integrates a 2x16 LCD, LEDs, UART, CAN interface, buzzer, test buttons and Jtag interface to create a versatile stand-alone test platform. The board itself is provided with plenty of example
programs to help you startup with your design quickly.

Source: www.embedded-computing.com

04 September 2006

Philips P89V51RD2 Microcontroller

I am using Philips P89V51RD2 as 8051 Microcontroller Unit (MCU). And I have been developing my code with Opensouce C Compiler SDCC. Please visit my Tools page for software preparation guides.

The P89V51RD2 is a 80C51 microcontroller with 64 kB Flash and 1024 bytes of data RAM. A key feature of the P89V51RD2 is its X2 mode option. The design engineer can choose to run the application with the conventional 80C51 clock rate (12 clocks per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput at the same clock frequency. Another way to benefit from this feature is to keep the same performance by reducing the clock frequency by half, thus dramatically reducing the EMI.

The Flash program memory supports both parallel programming and in serial In-System Programming (ISP). Parallel programming mode offers gang-programming at high speed, reducing programming costs and time to market. ISP allows a device to be reprogrammed in the end product under software control. The capability to field/update the application firmware makes a wide range of applications possible.

The P89V51RD2 is also In-Application Programmable (IAP), allowing the Flash program memory to be reconfigured even while the application is running.

Features

  • 80C51 Central Processing Unit

  • 5 V Operating voltage from 0 MHz to 40 MHz

  • 64 kB of on-chip Flash user code memory with ISP (In-System Programming) and IAP (In-Application Programming)

  • Supports 12-clock (default) or 6-clock mode selection via software or ISP

  • SPI (Serial Peripheral Interface) and enhanced UART

  • PCA (Programmable Counter Array) with PWM and Capture/Compare functions

  • Four 8-bit I/O ports with three high-current Port 1 pins (16 mA each)

  • Three 16-bit timers/counters

  • Programmable watchdog timer

  • Eight interrupt sources with four priority levels

  • Second DPTR register

  • Low EMI mode (ALE inhibit)

  • TTL- and CMOS-compatible logic levels

  • Brown-out detection

  • Low power modes

    o Power-down mode with external interrupt wake-up

    o Idle mode

  • DIP40 packages

Related Links
Product Page: http://www.semiconductors.philips.com/
Data Sheet: P89V51RB2_RC2_RD2-03.pdf
Boot Loader: p89v_lv51rd2_bl_upd_v5.zip
FlashMagic ISP Software: http://www.esacademy.com/

03 September 2006

Introduction to 8051 Microcontroller

The 8051 is an 8 bit microcontroller originally developed by Intel in
1980. It is the world's most popular microcontroller core, made by
many independent manufacturers (truly multi-sourced). There were 126
million 8051s (and variants) shipped in 1993!!

A typical 8051 contains:

  • CPU with boolean processor

  • 5 or 6 interrupts:
    2 are external

    2 priority levels

  • 2 or 3 16-bit timer/counters

  • programmable full-duplex serial port
    (baud rate provided by one of the timers)

  • 32 I/O lines (four 8-bit ports)

  • RAM

  • ROM/EPROM in some models

One strong point of the 8051 is the way it handles interrupts.
Vectoring to fixed 8-byte areas is convenient and efficient. Most
interrupt routines are very short (or at least they should be), and
generally can fit into the 8-byte area. Of course if your interrupt
routine is longer, you can still jump to the appropriate routine from
within the 8 byte interrupt region.

The 8051 instruction set is optimized for the one-bit operations so
often desired in real-world, real-time control applications. The
boolean processor provides direct support for bit manipulation. This
leads to more efficient programs that need to deal with binary input
and output conditions inherent in digital-control problems. Bit
addressing can be used for test pin monitoring or program control
flags.


See full information from 8051 FAQ
- http://www.faqs.org/faqs/microcontroller-faq/8051/