Translate

Saturday, September 6, 2014

How to Program a 8051 ATMEL Microcontroller?

Hi again! 

For today, I prepared a video clip on how to program an ATMEL 8051 Microcontroller.

First of all, prepare your program ahead of a time  in a clean sheet of paper. 
Your program can be composed of different jumps, loops, bit testing and setting of different flags.

It is on your own hands if it fails or not!

I already prepared the assembly code in my document. So this tutorial will be mainly focusing on how to program it, how to put codes, how to check your program and how to save it. ^_^

Enjoy it!



How to read the Instruction Set Table?

Reading the instruction set table is one of the most easiest way to do in this world! 

It is composed of rows and columns. 

You will notice it  in the pictures below.


You'll see the format of each instruction in the instruction set table.  

You can also see the designated numbers per column and row.

To be able to know the assembly code of each instruction , you'll just have to combine the numbers of each row and column.

For example, NOP instruction.
NOP instruction has a designated column number and a designated row number if you notice.

To get the first  number of its assembly code, know the column number where the instruction belong.
As NOP as our example, NOP belongs to column number 0.






To get the second number of its assembly code, trace its row number. The row number of NOP instruction is also zero.
That means, NOP instruction has a assembly code 00. 

So, that's it!! As simple as that!

Kindly comment things that makes you difficult to understand in this post. I am enthusiastic to answer them right away. Thanks!

Disclaimer: I don't own any single photos in this post.
Reference: 8051 Microcontroller Instruction Set. Atmel Corporation 2006.

Friday, September 5, 2014

ATMEL 8051 INSTRUCTION SET


Instruction Set
Program Status Word (PSW)
-contains several status bits that reflects the current state of the CPU
*Carry bit 
- carry bit in arithmetic operations serves as the “Accumulator” for a number of Boolean operations
*Auxiliary Carry (for BCD operations)
*2 Register Bank - selects bits
*Overflow flag
*2 user-definable status flags
*Parity bit – 1 if odd, 0 if even
Addressing Modes
*Direct Addressing
-operand is specified by an 8-bit address field in the instruction
-128 lowest bytes of internal Data RAM and SFRs can be directly addressed

*Indirect Addressing
-specific a register which contains the address of the operand
-Both internal and external RAM can be directly addressed

*Register Instructions
-Register banks R0 through R7, can be accessed by certain instructions which carry a 3-bit register specification within the opcode of the instruction. Instructions that access the registers this way are code efficient.

*Register-specific Instructions
-The opcode does itself. Instructions that refer to the accumulator as “A” assemble us accumulator-specific opcode.

*Immediate Constants
-The value of a constant can follow the opcode in Program Memory.
Ex. MOV A, #100
-Can also be specified as 64 in the digits.

*Indexed Addressing
-Only Program Memory can be accessed with indexed addressing, and it can only be read.
-Reading look-up tables in Program Memory.

Arithmetic Instruction
ADD 7F # (direct addressing)
ADD A, @ R0 (indirect addressing)
ADD A, R 7 (register addressing)
ADD, # 127 (immediate constant)
Logical Instructions
The instructions that perform Boolean operations (AND, OR, Exclusive OR, NOT) on bytes perform the operation on a bit-by-bit basis.
Data Transfers
*Internal Ram
-moving data around within the internal memory spaces, and the addressing modes that can be used with each one.
*External RAM
-Instructions that access external Data Memory. Only indirect addressing can be used.
Lookup Tables
-Instructions access only Program Memory, the lookup tables can be read, not updated.
Boolean Instructions
-Instructions that access these bits are not just conditional branches, but a complete menu of move, set, clear, compliment, OR and AND instructions.
*Relative Offset
Jump Instructions
-Conditional Jumps –Unconditional Jumps

Reference:
ATMEL 8051 Microcontrollers Hardware Manual. Atmel Corporation 2005.