Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

how can user enter input in 8051 assembly programming

Status
Not open for further replies.

sukanya

New Member
hi
i want to know that how do you write command in assembly language for the user to input some data.i will be working on 8051 family.
thank you
 
sukanya said:
hi
i want to know that how do you write command in assembly language for the user to input some data.i will be working on 8051 family.
thank you

If you're writing in assembler you will probably have to write the entire routine yourself, or try and download a suitable routine from somewhere. Obviously it will depend on how you wish to enter the data, there are many possibilities - among them are scanning single keys, scanning multiplexed keys, reading serial data from a keyboard.
 
If you work on PIC or motorola, 8051 input pin may be strange to you.
Unlike the others, there is no port direction control register. You cannot set the I/O to be input permenantly.

In 8051, if you want to read an I/O pin, you must first set the value to be 1. So, it the input is 1, it remain to be 1. If input is 0, then it will pull down the I/O to 0. After that, if you wish to read again, you gotta reset the I/O to 1.

That is somehow confusing and troublesome.
 
StupidDum: I don't think you're quite right about how the 8051 switches it's ports to inputs. The 8051 that I use has two port configurations: push-pull, and open collector. To make the port an input you set the mode to opencollector and then load a 1 to the port. This turns off the open collector transistor making the port a high impedance node. The external signal will now drive the port value. There is no need to reset the port to 1 after it is pulled low the input just needs a drive the input high. What you write to the port goes to turn on or off the transistors that drive the port pin. What you read when you read the port is the actual value on the output of the transistors( the value on the pin). This lets you write a 1 to the port (in open collector mode) and read a 0 (driven by the input signal)on the port. The value you wrote hasn't changed but the state of the pin has.

Brent
 
Yeah, direction register is on PIC, 8051 or 8951 you dont have to control the direction. But with port 0 of 8951, you have to put pullup resistors.

With other ports, you don't have to put pullup resistors.

To write asm to 8951, you may download the datasheet of at89c51.

it may have some differences such as the interrupts. The interrupts on PIC is start at 0x0004 but the different interrupts on 8951 have different interrupts addresses.

Like stuff, I don't like 8951 even I work with 8951 as beginning learning microcontroller and I wrote many applications on that chips. If anyone ask, I would recommend to use PIC.
 
assembly command

Find the assembly language instruction set for your micro controller,
Each instruction is explained with example on the user guides.

Once you write assembly language instructions, use compiler to compile it. It will convert your written assembly instructions to series of Hex numbers. Those hex numbers can be loaded to micro controller memory.

It is given on user guid how to load it.

good luck

mahinda
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top