Questions tagged [8051]

The 8051 is a Harvard architecture, single chip microcontroller (µC) which was developed by Intel in 1980 for use in embedded systems. The 8051 family of microcontrollers and derivatives continue to remain popular with a vast community of hobbyists and professionals.

The 8051 is a Harvard architecture, single chip microcontroller (µC) which was developed by Intel in 1980 for use in embedded systems. Intel fabricated the original 8051 known as MCS-51. The 8051 family of microcontrollers and derivatives continue to remain popular with a vast community of hobbyists and professionals. Today a vast range of faster and/or functionally enhanced 8051-compatible devices are manufactured by more than 20 independent manufacturers.

Before you start

Please browse the list of frequently asked questions to see if your question is similar to one that has already been answered. If your question is not 8051-programming related, it may be more appropriate for Electronics and Robotics - Stack Exchange since questions tagged 8051 are found there as well.

If you haven't found an answer to your question after searching, we're here to help!

Help us help you

Please help keep your question readable by using proper formatting. When you post a question, please monitor it for activity because more information or clarification might be required in order to provide a good answer.

Explain what you tried and where you're stuck (preferably with code examples) if applicable.

Important notes that may save you time

  • The datasheet for a specific device or family of devices useful information information and is often a good place to start. Datasheets are typically available on the device manufacturer's website.

  • The 8052.com web site is dedicated exclusively to the 8052 microcontroller, related products (both hardware and software), and 8052 derivative chips. This includes the traditional 8052, 8051, 8032, and 8031 along with more modern derivatives such as those by Atmel, NXP, Silicon Laboratories, and many others.

  • The Wikipedia article has an overview of the ISA's registers and instructions.

473 questions
17
votes
11 answers

Unravelling Assembly Language Spaghetti Code

I've inherited a 10K-line program written in 8051 assembly language that requires some changes. Unfortunately it's written in the finest traditions of spaghetti code. The program--written as a single file--is a maze of CALL and LJMP statements…
bitFlipper
  • 475
  • 5
  • 20
16
votes
6 answers

Is there a way to address a single bit in C?

I've done some researching on bit addressable microcontrollers. The only one that came across in my path is the Intel MCS-51(wiki page) which is still used very commonly today... I was wondering if you can directly address a bit in C, for example on…
Ban Piao
  • 161
  • 1
  • 1
  • 6
10
votes
5 answers

When do I use xdata?

I am new at embedded system programming. I am working on a device that uses an 8051 chipset. I have noticed in the sample programs that when defining variables, sometimes they use the keyword xdata. like this... static unsigned char xdata…
PICyourBrain
  • 9,976
  • 26
  • 91
  • 136
9
votes
11 answers

C++ for 8051 microcontroller?

Could someone please tell me if it's possible to burn an 8051 microcontroller with a C++ program? I've tried searching about it online but can't seem to find out for sure if it's possible or not. Keil uses C, but the program I need to write is very…
CodeConfused
  • 325
  • 3
  • 6
  • 10
9
votes
4 answers

"printf" in microcontroller, what is it for?

I see "printf" instruction in sample codes of c language for microcontroller particularly in 8051. Since microcontrollers has no fixed output display what is the use of the "printf" instruction?
LEMUEL ADANE
  • 8,336
  • 16
  • 58
  • 72
8
votes
2 answers

Optimising SHA-1 for small input

I'm hoping to optimise an implementation of SHA-1 for an 8-bit MCU (8051-based). The input data is only 8-bytes, so I wonder if something could be done to improve this macro: #define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n))) The issue I…
Kar
  • 6,063
  • 7
  • 53
  • 82
7
votes
2 answers

How do I write an efficient switch() in 8051 assembly?

If I ever want to create a finite state machine in 8051 assembly, I'll need an efficient equivalent of C switch() expression. [for this question, let us disregard the fall-through behavior, both retaining and dropping it is acceptable]. There are a…
SF.
  • 13,549
  • 14
  • 71
  • 107
6
votes
1 answer

Why do some 8051 program ends with the code "LOOP: SJMP LOOP"

Almost all the simple 8051 programs I have seen so far ends with the code LOOP: SJMP LOOP. From my understanding I think the above instruction creates an infinite loop by calling the same instruction again and again. But what is the purpose of…
Sparkzz
  • 367
  • 5
  • 14
6
votes
7 answers

What techniques are available for memory optimizing in 8051 assembly language?

I need to optimize code to get room for some new code. I do not have the space for all the changes. I can not use code bank switching (80c31 with 64k).
Paul
  • 198
  • 1
  • 9
  • 22
6
votes
6 answers

Advantages of atmega32

What are the advantages of using ATmega32 than other microcontrollers? Is it better than PIC, ARM, and 8051?
Komal
  • 85
  • 1
  • 2
  • 7
6
votes
1 answer

How to configure 8051 pins as input/output?

In pic microcontroller TRIS register determines whether port would act as input or output and PORT register would determine the content, what should be written (in case of output) or read (in case of input). But in 8051 there isn't any such kind of…
6
votes
2 answers

8051 external interrupt

how to enable external interrupt of 8051?
martin
  • 643
  • 1
  • 10
  • 19
6
votes
2 answers

How to make 8051 emulator

For learning purpose i intend to start building a 8051 microcontroller emulator. I am comfortable programming in C/C++/C#. This is no class project etc but a learning initiative from my side. I did found quite a lot of questions discussing this.…
K Singh
  • 1,710
  • 1
  • 17
  • 32
6
votes
4 answers

How can I send a string serially from an 8051 only ONCE?

I am making an 8051 microcontroller communicate wirelessly with a computer. The microcontroller will send a string to its serial port (DB9) and the computer will receive this string and manipulate it. My problem is that I do not know how to make the…
CodeConfused
  • 325
  • 3
  • 6
  • 10
5
votes
9 answers

How do I mark code with side effects?

I'm working on a project on an 8051 where every byte counts. As such, I am using some global variables where I normally wouldn't. The normal method of passing pointers into a function adds too much overhead here. I have a number of functions that…
daotoad
  • 26,689
  • 7
  • 59
  • 100
1
2 3
31 32