8051 Tutorial 6: 8051 Interrupts Programming in C

What is an interrupt?

An interrupt is an asynchronous signal that needs attention. An interrupt stops the CPU of a microcontroller, leaving the tasks that it is currently doing, to give attention to the interrupt signal. Once the attention has been given to the interrupt signal, the CPU goes back to its unaccomplished task before the interrupt has occured and continues the task.

The Interrupts of AT89C2051

The interrupts of AT89C2051 is compatible with the interrupts of the original 8051 microcontroller. It has 6 interrupts sources ( 5 interrupts + RESET). The interrupt sources of AT89C2051 are the following:

Interrupt Source Priority Number
1 RESET RST N/A
2 External Interrupt 0 IE0 0
3 Timer 0 Interrupt TF0 1
4 External Interrupt 1 IE1 2
5 Timer 1 Interrupt TF1 3
6 UART Interrupt RI or TI 4

Please note that in this tutorial, we will not consider the interrupt from RESET.

The table above shows the interrupt sources of AT89C2051 and their respective interrupt priority number. Knowing the priority number is important specially if two different interrupt sources occur at the same time. [Read more...]

Pages: 1 2 3 4

8051 Tutorial 5: 8051 UART Programming in C

What is UART?

UART stands for Universal Asynchronous Receiver/Transmitter. As its name implies, it is universal. It can be used to establish a communication between a microcontroller and another device – microcontroller, USB controller, Bluetooth modules, GSM modules, GPS modules, personal computers, etc.

I am not going to discuss the UART protocol here. If UART is still unknown to you, you may read this article from wikipedia first.

 

What is RS-232?

RS-232 is a standard for serial transmission of data between a DTE (Data Terminal Equipment) and a DCE (Data Circuit-terminating Equipment). It is commonly found in desktop computers where it is commonly referred as COM port. You can read this wikipedia article for more info about the RS-232 standard.

 

AT89C2051 UART

The AT89C2051 has one UART port. Its TXD (Transmit) pin is the same as its P3.1 pin. Its RXD (Receive) pin is the same as its P3.0 pin.

[Read more...]

Pages: 1 2 3 4

8051 Tutorial 4: 8051 Timer/Counter Programming in C

This tutorial is about using the internal timers/counters of 8051. This will tackle the registers associated with the internal timers/counters of 8051 and this will also enumerate the steps on using the timers/counters of an 8051 microcontroller.

The Timers/Counters of AT89C2051

The AT89C2051 has two 16-bit Timer/Counters: Timer0 and Timer1. This means that it can time/count from 0 to 65535 (2^16-1). The timers can be used to generate accurate delays and the counters can be used to count events. An event can be anything. It can be a pulse, a push, a pull, or any stimulus. [Read more...]

Pages: 1 2 3

8051 Tutorial 3: I/O Port Programming in C

This tutorial will introduce you the basics about programming the input and output ports on an 8051 microcontroller using C language. Therefore, it is recommended that the reader is familiar or has basic knowledge about C programming language and electronics circuit analysis. I am going to use Atmel‘s AT89C2051 as an example for the 8051 microcontroller and the C compiler that I am going to use is the RC-51 which is included with the Free Evaluation 8051 Software Toolset of Raisonance. You may see this for more info about the toolset or you may download the free evaluation 8051 Software Toolset  here(RKit-Eval51). See this tutorial for a quick start guide with this software.

For an introduction about AT89C2051, see this.

AT89C2051 General Input and Output Ports

The original 8051 microcontroller (40 pins)  contains 4 digital input and output ports which are P0, P1, P2, and P3. Its little brother, AT89C2051 (20pins), only contains two bidirectional input and output ports which are P1 and P3. Both ports are one-byte (8-bits) wide and each pin of each port can be accessed externally (see the pin diagram below) except bit 6 of P3 or P3.6.

[Read more...]

Pages: 1 2 3

8051 Tutorial 2: Raisonance’s Free Evaluation 8051 Software Toolset

In this tutorial, I am going to discuss how to create a C project intended for 8051 family of microcontrollers. I am going to use the free evaluation toolkit for 8051 from Raisonance. This tutorial aims to discuss the basics of creating project using the toolkit from Raisonance. However, the reader is advised to read the documentation of the said toolkit for more advanced usage and configuration.

What is the Free Evaluation 8051 Software Toolset of Raisonance?

The Free Evaluation 8051 Software Toolset of Raisonance is a free development tool provided by Raisonance that enables developers to compile and debug applications using 8051 microcontrollers. This toolset includes the following:

  • Ride6 integrated development environment
  • RC-51 ANSI C compiler, output up to 4Kbytes of code
  • MA-51 Macro Assembler, output up to 4Kbytes of code
  • LX-51 Code Banking Linker, output up to 4Kbytes of code
  • KR-51Tiny RTOS, supports up to 3 tasks
  • SIMICE-51 Simulator, debug up to 4Kbytes of code

For more info about this toolset, you may visit this. You may also download the toolset (look for RKit-Eval51) here. [Read more...]

Pages: 1 2