Programing AT89C2051 using SDCC compiler on Debian Linux

My Homemade AT89C2051 Development Board

First and foremost we need to install a compiler and we need a programmer to load the code into the microcontroller. In my case, I use TL866A Universal Programmer.

SDCC
minipro

So let’s start with the installation of the compiler:

// install SDCC package:
apt install sdcc

// test instalation
sdcc --version

TL866A Universal Programmer

The next step is to install the programmer software:

// install dependencies for minipro
apt install build-essential pkg-config git libusb-1.0-0-dev

// get source code of minipro
git clone https://gitlab.com/DavidGriffith/minipro.git

// compile minipro software
cd minipro
make

// install application
sudo make install

// udev configuration
sudo cp udev/*.rules /etc/udev/rules.d/
sudo udevadm trigger

// add user to the plugdev group
sudo usermod -a -G plugdev YOUR-USER

// test instalation
minipro --version

For this occasion, I wrote the Blink c program for AT89C2051 and compiled it using SDCC on Debian Linux.

// ********************************************************
// Program:     Blink LED example
// Author:      Elvis Baketa
// Processor:   AT89C2051
// Oscillator:  12 MHz
// Compiler:    SDCC (Linux)
// Version:     0.1
// Comment:     
// ********************************************************

#include "at89x051.h"

// declare function
void delayms(void);
void delay(int data);

// main function
void main(void)
{
    // declare variable
    int i = 0;
    
    // run once
    P1_0 = 1;
    
    // loop forever
    while(1)
    {
        // turn LED on
        P1_0 = 0;
        // wait 1 second
        delay(1000);
        // turn LED off
        P1_0 = 1;
        // wait 1 second
        delay(1000);
    }
}

// delay one milisecond
void delayms(void)
{
    int i;
    // count to 33 for 1 ms delay
    for (i = 0; i < 34; i++);
}

// amount of milisecond to delay
void delay(int data)
{
    int i;
    for (i = 0; i < data; i++)
    {
        delayms();
    }
}

You can find source code on GitHub repo blink at89c2051.

Until next time.

MiniPRO TL866xx universal programmer Linux installation.

The TL866A universal programmer is a chip programmer that allows us to write or read chip memory such as microcontrollers, EEPROM memory, etc. This very popular device, unfortunately, comes with software only for the Windows operating system. But there is an open-source alternative that allows the use of this device on the Linux operating system, thanks to David Griffith and his project on GitLab.



Installation:

Install build dependencies:

sudo apt install build-essential pkg-config git libusb-1.0-0-dev

Get source code:

git clone https://gitlab.com/DavidGriffith/minipro.git

Compile source code:

cd minipro
make

Install application:

sudo make install

Udev configuration:

sudo cp udev/*.rules /etc/udev/rules.d/
sudo udevadm trigger

Add regular user to the plugdev group:

sudo usermod -a -G plugdev YOUR-USER

Reboot your system.

Basic usage:

Show all available options:

minipro

Show version information:

minipro -V

Read from the device and save to a file:

minipro -p W29C020C -r test_w29c020c.bin

Erase the device:

minipro -p W29C020C -E

Blank check:

minipro -p W29C020C -b

Write from file to the device:

minipro -p W29C020C -w test_w29c020c.bin

I am very pleased with this installation, everything went without a single problem and the universal programmer works flawlessly. Many thanks to the open-source community and fingers up for David’s project on GitLab.

Stay healthy and safe till the next time!