There is no easy-to-use IDE like keli under Linux to develop the 51 microcontroller. The development environment can only be built by yourself.
Step 1: Install cross-compilation tools
a) Install SDCC
sudo apt-get install sdcc
b) Test whether SDCC is available. This is a simple running water lamp code test.c found online, used for testing.
#include "8051.h"
#define uint unsigned int
#define uchar unsigned char
uchar tab[8] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
void Delay(uint xms)
{
uint i,j;
for(i=xms;i>0;i--)
for(j=110;j>0;j--);
}
void main()
{
uchar i;
while(1)
{
for(i=0;i<8;i++)
{
P1 = tab[i];
Delay(100);
}
}
}12345678910111213141516171819202122232425
Compile it: sdcc test.c
This many files will be generated:
test.lk test.map test.rel test.sym test.asm test.ihx test.lst test.mem test.rst
We only need test.ihx among them
packihx file.ihx >file.hex Convert to hex file
Then download the hex2bin file at the URL (http://sourceforge.net/projects/hex2bin/files/latest/download). Command: hex2bin sourcefile.hex. The sourcefile.bin file will then be generated.
hextobin file.hex generates bin file
Note: In order to facilitate calling hex2bin in the future, you can add the path to the .bashrc file
Add the folder location of Hex2bin to the last line of ~/.bashrc
PATH=$PATH:/home/leo/workspace/c51/Hex2bin-2.31
You can write a makefile to make compilation easier
This is the makefile I wrote:
test.hex : test.c
sdcctest.c
packihx test.ihx > test.hex
hex2bin test.hex
clean:
rm -rf *.asm *.lst *.mem *.rst *.lnk *.rel *.sym *.ihx *.hex *.map
~ 1234567
Step 2: Install the programming tool
a) Download stcflash: github.com/laborer/stcflash, which is a software written in python to program bin files to microcontrollers.
b) Installation environment: sudo apt-get install python-serial
c) Flashing: sudo python ./stcflash.py test.bin
Previous article:Things to note when developing 51 microcontroller operating system
Next article:51 microcontroller ultrasonic ranging program code sharing
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Let’s talk about the “Three Musketeers” of radar in autonomous driving
- Why software-defined vehicles transform cars from tools into living spaces
- How Lucid is overtaking Tesla with smaller motors
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Three steps to govern hybrid multicloud environments
- Three steps to govern hybrid multicloud environments
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- 【LAUNCHXL-CC1350-4】- 2: This is somewhat similar to what I imagined before and somewhat different
- 【ART-Pi Review】Part 3: Onboard Storage - SDRAM
- Please help me check if 28335 is down
- Code compression technologies for several mainstream embedded architectures
- 【Laser target detector】Belated unboxing, RPI400 unit only
- Getting Started Using TouchGFX to Develop STM32 Interface Applications (Part 1) - Software Installation and Hello World
- psoc creator soft imitation function
- Developer Case: Design of Smart Agriculture Based on Gizwits IoT and RT-Thread
- Basic Theory of System Timing
- GD32L233C-START evaluation development environment construction and official DEMO download test