Tuesday, December 26, 2006
New book explains how to build Linux 2.6 kernels
I think, this book is a starting point when you would like to learn the Embedded Linux for a Microcontroller, also the Real Time Operating System.
Source: http://oreilly.com/emails/press/9780596100797.html
Buy Linux Kernel in a Nutshell from Amazon.com
Sunday, December 17, 2006
Eclipse for SDCC
Eclipse is an open source community whose projects are focused on building an open development platform comprised of extensible frameworks, tools and runtimes for building, deploying and managing software across the lifecycle. Eclipse is used for Enterprise Development, Embedded and Device Development, Rich Client Platform, Application Frameworks and Language IDE.
The CDT is Eclipse's C/C++ Development Tooling project. It is an industrial strength C/C++ IDE that also serves as a platform for others to provide value added tooling for C/C++ developers.
The eclipseSDCC project aims to provide full support for the open source Small Device C Compiler (SDCC) from within the eclipse/CDT development environment. This allows embedded 'C' applications for 8051 and Z80 devices to be developed using the fully featured eclipse IDE. EclipseSDCC supports CDT managed make projects. In managed make projects CDT manages the build process by creating and maintaining the underlaying makefiles. CDT keeps track of source dependencies and can automatically rebuild the target when needed.
To install (for Windows)
- It requires Java Runtime Environment (JRE), I download only JRE not SDK and install it.
- Downlaod Eclipse SDK 3.2.1 for Windows (120 MB) and extract it to c:/eclipse. In the directory it contains eclipse.exe which is an executable.
- Download CDT 3.1.1 (September 29, 2006) and extract it c:/eclipse, this will prompt to replace plugins and features directory.
- If you have already installed SDCC for Window, skip this step. If you have no SDCC installed, read this first.
- Download eclipseSDCC-1.0.0, when you extract the file, it contains plugins and features directory. Copy the two direct to c:\eclipse.
Eclipse for SDCC is quite large when compared it MIDE-51. However, you can manage project in Eclipse whereas MIDE-51 still have no this feature in the present version. Here is a screen shot, you should see this dialog.
Related Links
Friday, December 1, 2006
What's coming up, MIDE-51?
The current version is 0.2.5.10. The author is working for next major version 0.3.0.0, which supports SDCC multiple files project style. Hopefully, he will finish this version soon.
Wednesday, November 29, 2006
128KB Flash 8051 MCU from Atmel
A key feature is the on chip debug capability that enables low cost emulation. The hardware debug system with Windows IDE interface allows the user to access debugging functions built into the AT89C51RE2 resulting in faster development and verification of user code in real time.
The AT89C51RE2 is available in 44-pin PLCC and VQFP packages at $4.80 for 10,000 units.
Atmel offers the AT89STK-11, a starter kit for $99, to evaluate the AT89C51RE2; designers can either run the demonstration program or their own application. A new low-cost on-chip debug tool, AT89OCD-01 will be available by the end of November 2006.
Monday, November 27, 2006
Low-cost ARM7TDMI Evaluation Board based on STR730FZ2T6
Features
- 256 Kbytes of flash
- 16 Kbytes of RAM
- up to 16-channel 10-bit ADC
- 20 timers
- 4xUARTs
- 3xCANs
- SPI
- I2C
- DMA
- RTC
- PWM
- 112 GPIO
The board integrates a 2x16 LCD, LEDs, UART, CAN interface, buzzer, test buttons and Jtag interface to create a versatile stand-alone test platform. The board itself is provided with plenty of example programs to help you startup with your design quickly.
Source: www.embedded-computing.com
ARM offers OpenMAX DL, free video codec software library
OpenMAX is a royalty-free, cross-platform API developed by the Khronos Group that provides a comprehensive media codec and application portability by enabling accelerated multimedia components to be developed, integrated and programmed across multiple operating systems and silicon platforms. [OpenMAX]
ARM said it plans to create a series of libraries including an implementation that will take full advantage of the ARMv6 architecture found in the ARM11 family and an implementation for the NEON signal processing technology found in the Cortex-A8 processor.
Source: www.electronicsweekly.com
Saturday, November 25, 2006
A Real-Time Operating System (RTOS) for the 8051
FreeRTOS.orgTM is a portable, open source, mini Real Time Kernel - a free to download RTOS. It have been ported to support several microcontroller architectures - ARM7, ARM CORTEX M3, 8051, AVR (MegaAVR), x86, PIC18, PIC24, dsPIC, HCS12, H8S, RDC, ColdFire. FreeRTOS is licensed under a modified GPL and can be used in commercial applications under this license.
For the 8051, this RTOS have been ported to Cygnal (Silicon Labs) 8051. This is the starting point for anyone who would like to study the Operating System and Embedded Design on 8051. The Cygnal port was developed on a C8051F120-TB prototyping board fitted with a 8051F120 microcontroller. The freeware SDCC compiler was used along with the Cygnal IDE.
Building and executing the RTOS demo application
After downloads the freeRTOS source file (.exe or .zip), I extract the file to C:\FreeRTOS. The demo application for Cygnal 8051 is located in C:\FreeRTOS\Demo\Cygnal. To compiler this demo, it is require SDCC (see how to install) and GNU make. For Gnu make, I download UnxUtils.zip then extract it to C:\UnxUtils and finally edit PATH to C:\UnxUtils\usr\local\wbin (see how to edit PATH on 2000 and XP). In DOS Command Shell, change directory (cd) to C:\FreeRTOS\Demo\Cygnal and type make, the final product is main.ihx which the demo real time application for Cygnal 8051. However. the size of this file is quiet big, 72k. I have succeed compiling with SDCC 2.5.x but failed for SDCC 2.6.x.
In the conclusion, The demo application of the opensource freeRTOS have been ported to Cygnal 8051 which contains the demonstration source code. This is an avenue to learn the Real Time Operating System for the others 8051 chip.
Tuesday, November 21, 2006
A Simulator for P89V51RD2
- Timer/Counter 2
- PCA (Programmable Counter Array)
- Watchdog timer
To use, enter this commands:
$s51 -t 89c51r
which prompt you to uCsim command shell. You can view the special modules supported by uCsim by enter this in the uCsim shell:
0>conf
ucsim version 0.5.4
Type of microcontroller: 89C51R CMOS
Controller has 13 hardware element(s).
timer0[0]
timer1[1]
uart[0]
port[0]
port[1]
port[2]
port[3]
irq[0]
_51_dummy[0]
timer2[2]
wdt[0]
pca[0]
_89c51r_dummy[0]
Although this simulator is based on command line, it is free and powerful for the modern 8051 chips.
uCsim home: http://mazsola.iit.uni-miskolc.hu/%7Edrdani/embedded/s51/
Wednesday, November 15, 2006
Installing SDCC on Fedora Core 6
$tar -xvfz sdcc-src-xxx-xxx.tar.bz2If it succeed, you should have these directories:
$cd sdcc
$./configure --prefix=/usr
$make
$make install
/usr/bin for execute files
/usr/share/sdcc/doc for documentation
/usr/share/sdcc/include for header files
/usr/share/sdcc/lib for libraries
I tested it with this simple code, I edited with gedit:
#include <8051.h>
void min() {
unsigned char var_1;
var_1 = 0xFF;
}
then saved it, let say test.c. To compile I use this command:
$sdcc test.cand I found the test.ihx file in that directory which is the expected output.
Friday, November 10, 2006
uCsim: the 8051 simulator for SDCC
For the 8051, the recognized types are: 51, 8051, 8751, C51, 80C51, 87C51, 31, 8031, C31, 80C31, 52, 8052, 8752, C52, 80C52, 87C52, 32, 8032, C32, 80C32, 51R, 51RA, 51RB, 51RC, C51R, C51RA, C51RB, C51RC, 89C51R, 251, C251, DS390, DS390F.
uCsim is available for two platforms: DOS (MCS51 only) and UNIX but DOS version is not supported any more. DOS version is not finished so I call it demo version and it is available in binary only. Limitations of DOS version are:
- There is no built in help available;
- Some of the utilities are not working, for example calculator, bit simulator;
- Serial line works in mode 1 independently of mode bits.
Starting the Simulator
There are separate programs to simulate different microcontroller families:
MCS51 family is simulated by s51
AVR family is simulated by savr
Z80 processor is simulated by sz80
XA family is simulated by sxa
HC08 processor is simulated by shc08
The program can be started using following command:
C:\> s51 [input file]
Parameter is optional. If it specified it must be the name of an Intel hex file.For more details, please see its documentation. This is an overview and I will write about this simulator later.
Wednesday, November 8, 2006
Migrating from demo compilers to SDCC
- check whether endianness of the compilers differs and adapt where needed.
- check the device specific header files for compiler specific syntax. Eventually include the file
> to allow using common header files. (see f.e. cc2510fx.h). - check whether the startup code contains the correct initialization (watchdog, peripherals).
- check whether the sizes of short, int, long match.
- check if some 16 or 32 bit hardware registers require a specific addressing order (least significant or most significant byte first) and adapt if needed (first and last relate to time and not to lower/upper memory location here, so this is not the same as endianness).
- check whether the keyword volatile is used where needed. The compilers might differ in their optimization characteristics (as different versions of the same compiler might also use more clever optimizations this is good idea anyway). See Common interrupt pitfall: variable not declared volatile.
- check that the compilers are not told to supress warnings.
- check and convert compiler specific extensions (interrupts, memory areas, pragmas etc.).
- check for differences in type promotion. Especially check for math operations on char or unsigned char variables. For the sake of C99 compatibility SDCC will probably promote these to int more often than other compilers. Eventually insert explicit casts to (char) or (unsigned char). Also check that the ~ operator is not used on bit variables, use the ! operator instead. See sections TIPS and Compatibility with previous versions.
- check the assembly code generated for interrupt routines (f.e. for calls to possibly non-reentrant library functions).
- check whether timing loops result in proper timing (or preferably consider a rewrite of the code with timer based delays instead).
- check for differences in printf parameters (some compilers push (va_arg) char variables as int others push them as char. See section Compatibility with previous versions).
- check the resulting memory map. Usage of different memory spaces: code, stack, data (for mcs51/ds390 additionally idata, pdata, xdata). Eventually check if unexpected library functions are included.
Friday, October 20, 2006
Robot technology running fast in Japan
MANOI (humanoid robot) is a product of KYOSHO. Please see the Design, Mechanism and Playing Events Innovation.
Sunday, October 15, 2006
High performance driving of the Remote control Segway (a self balancing robot).
This video shows the self-balancing robot spinning as it drives. All that the user needs to do is use the remote control to command direction and turning direction. The microcontroller does the rest.
This is a remote control Segway (a mini self balancing robot), named the Teetering Buffalo, built at Georgia Tech by graduate students Adam Cardi, Aaron Enes, and Matt Wagner.
Aaron Enes at Georgia Tech
21 sec - Jan 13, 2006
www.prism.gatech.edu
Tuesday, September 19, 2006
P89LPC9381; 8-bit microcontroller with accelerated two-clock 80C51 core 4 kB 3 V byte-erasable flash with 10-bit ADC
The P89LPC9381 is a single-chip microcontroller, available in low-cost packages, based on a high performance processor architecture that executes instructions in two to four clocks, six times the rate of standard 80C51 devices. Many system-level functions have been incorporated into the P89LPC9381 in order to reduce component count, board space, and system cost.
- Principal features
- 4 kB byte-erasable flash code memory organized into 1 kB sectors and 64 B pages. Single-byte erasing allows any byte(s) to be used as non-volatile data storage.
- 256 B RAM data memory on-chip RAM.
- 8-input multiplexed 10-bit ADC. Two analog comparators with selectable inputs and reference source.
- Two 16-bit counter/timers (each may be configured to toggle a port output upon timer overflow or to become a PWM output) and a 23-bit system timer that can also be used as a RTC.
- Enhanced UART with fractional baud rate generator, break detect, framing error detection, and automatic address detection; 400 kHz byte-wide I2C-bus communication port and SPI communication port.
- High-accuracy internal RC oscillator option allows operation without external oscillator components. The RC oscillator option is selectable and fine tunable.
- 2.4 V to 3.6 V VDD operating range. I/O pins are 5 V tolerant (may be pulled up or driven to 5.5 V).
- 28-pin TSSOP package with 23 I/O pins minimum and up to 26 I/O pins while using on-chip oscillator and reset options.
- A high performance 80C51 CPU provides instruction cycle times of 111 ns to 222 ns for all instructions except multiply and divide when executing at 18 MHz. This is six times the performance of the standard 80C51 running at the same clock frequency. A lower clock frequency for the same performance results in power savings and reduced EMI.
- Serial flash ICP allows simple production coding with commercial EPROM programmers. Flash security bits prevent reading of sensitive application programs.
- Serial flash ISP allows coding while the device is mounted in the end application.
- In-Application Programming of the flash code memory. This allows changing the code in a running application.
- Watchdog timer with separate on-chip oscillator, requiring no external components. The watchdog prescaler is selectable from eight values.
- Low voltage reset (brownout detect) allows a graceful system shutdown when power fails. May optionally be configured as an interrupt.
- Idle and two different power-down reduced power modes. Improved wake-up from Power-down mode (a LOW interrupt input starts execution). Typical power-down current is 1 uA (total power-down with voltage comparators disabled).
- Active-LOW reset. On-chip power-on reset allows operation without external reset components. A reset counter and reset glitch suppression circuitry prevent spurious and incomplete resets. A software reset function is also available.
- Configurable on-chip oscillator with frequency range options selected by user programmed flash configuration bits. Oscillator options support frequencies from 20 kHz to the maximum operating frequency of 18 MHz.
- Oscillator fail detect. The watchdog timer has a separate fully on-chip oscillator allowing it to perform an oscillator fail detect function.
- Programmable port output configuration options: quasi-bidirectional, open-drain, push-pull, input-only.
- Port 'input pattern match' detect. Port 0 may generate an interrupt when the value of the pins match or do not match a programmable pattern.
- LED drive capability (20 mA) on all port pins. A maximum limit is specified for the entire chip.
- Controlled slew rate port outputs to reduce EMI. Outputs have approximately 10 ns minimum ramp times.
- Only power and ground connections are required to operate the P89LPC9381 when internal reset option is selected.
- Four interrupt priority levels.
- Eight keypad interrupt inputs, plus two additional external interrupt inputs.
- Schmitt trigger port inputs.
- Second data pointer.
- Emulation support.
Additional features
Friday, September 15, 2006
Distance Measurement Sensor
Features
- Less influence on the color of reflective objects, reflectivity
- Line-up of distance output/distance judgement type
Distance output type (analog voltage) : GP2Y0A21YK
Detecting distance : 10 to 80cm
Distance judgement type : GP2Y0D21YK
Judgement distance : 24cm
(Adjustable within the range of 10 to 80cm [Optionally available]) - External control circuit is unnecessary
- Low cost
Applications
- TVs
- Personal computers
- Cars
- Copiers
- Robots
The output of this sensor is analog therefore it need Analog to Digital Converter (ADC) to interface the 8051. I use ads7841 as ADC (see this article).
The graph of Analog voltage output versus distance to reflective object are shown in Fig.1. When I plot Analog voltage output versus inverse number distance, I found the linear relation shown in Fig.2.
Fig. 2 Analog voltage output (V) versus inverse number distance (1/cm).
The linear equation is y = 20.99x + 0.19, where y is voltage output and x invert distance. Notice that the voltage output I can trust are about 0.4 to 2.8 V.
This is an example code how to interface the distance sensor to 8051. I use SDCC as C Compiler.
#include <8051.h>
#include "ads7841.h"void main()
{
float x,y; // Distance and Analog voltage output
y = analog(0); // Read volt out if the sensor connect to channel 0 of ADS7841
y = 0.00122*y; // Convert BCD to DEC by multiply voltage by 5/4096
if ( (y > 0.4) && (y < 2.8) ) {
x = (y-0.19)/20.99; // Solve the linear equation
x = 1/x; // Inverse back get distance in cm.
}
}
Source:
test_irsensor.c
characteristic.txt (For plot with Spreadsheet)
Related Links
GP2Y0A21YK/GP2Y0D21YK Datasheet
Analog to Digital (ADS7841) Interfacing
Servo Motor Control
Servos
Servos are DC motors with built in gearing and feedback control loop circuitry. And no motor drivers required. They are extremely popular with robot, RC plane, and RC boat builders. Most servo motors can rotate about 90 to 180 degrees. Some rotate through a full 360 degrees or more.
However, servos are unable to continually rotate, meaning they can't be used for driving wheels, unless they are modified (how to modify), but their precision positioning makes them ideal for robot legs and arms, rack and pinion steering, and sensor scanners to name a few. Since servos are fully self contained, the velocity and angle control loops are very easy to impliment, while prices remain very affordable. To use a servo, simply connect the black wire to ground, the red to a 4.8-6V source, and the yellow/white wire to a signal generator (such as from your microcontroller). Vary the square wave pulse width from 1-2 ms and your servo is now position/velocity controlled.
PWM
Pulse width modulation (PWM) is a powerful technique for controlling analog circuits with a processor's digital outputs. PWM is employed in a wide variety of applications, ranging from measurement and communications to power control and conversion. The general concept is to simply send an ordinary logic square wave to your servo at a specific wave length, and your servo goes to a particular angle (or velocity if your servo is modified). The wavelength directly maps to servo angle.The standard time vs angle is represented in this chart:
Figure: Pulse for controlling a Servo motor
Programmable Counter Array (PCA)
Module 0 is connected to P1.3 (CEX0), module 1 to P1.4 (CEX1), etc. Registers CH and CL contain current value of the free running up counting 16-bit PCA timer. The PCA timer is a common time base for all five modules and can be programmed to run at: 1/6 the oscillator frequency, 1/2 the oscillator frequency, the Timer 0 overflow, or the input on the ECI pin (P1.2). The timer count source is determined from the CPS1 and CPS0 bits in the CMOD SFR.
In the CMOD SFR there are three additional bits associated with the PCA. They are CIDL which allows the PCA to stop during idle mode, WDTE which enables or disables the Watchdog function on module 4, and ECF which when set causes an interrupt and the PCA overflow flag CF (in the CCON SFR) to be set when the PCA timer overflows. The Watchdog timer function is implemented in module 4 of PCA. Here, we are interested only PWM mode.
8051 Pulse width modulator mode
All of the PCA modules can be used as PWM outputs. Output frequency depends on the source for the PCA timer. All of the modules will have the same frequency of output because they all share one and only PCA timer. The duty cycle of each module is independently variable using the module's capture register CCAPnL.When the value of the PCA CL SFR is less than the value in the module's CCAPnL SFR the output will be low, when it is equal to or greater than the output will be high. When CL overflows from FF to 00, CCAPnL is reloaded with the value in CCAPnH. this allows updating the PWM without glitches. The PWM and ECOM bits in the module's CCAPMn register must be set to enable the PWM mode. For more details see P89V51RD2 datasheet.
This is an example how to control servos with 8051 by using PWM. The schematic is shown below. I use P1.4 (CEX1) to control the left servo and P1.2 (CEX2) to control the right servo. Here, I use GWS servo motor model S03T STD. I need three states of duty cycle:
- 20 ms to Stop the servo
- 1 ms to Rotate Clockwise
- 2 ms to Rotate Counter-clockwise
Calculation for duty cycle (for XTAL 18.432 MHz with 6 Clock/Machine cycle)
- Initial PWM Period = 20mS (18.432MHz /6-Cycle Mode)
- Initial PCA Count From Timer0 Overflow
- 1 Cycle of Timer0 = (1/18.432MHz)x6 = 0.326 uS
- Timer0 AutoReload = 240 Cycle = 78.125 uS
- 1 Cycle PCA = [(1/18.432MHz)x6]x240 = 78.125 uS
- Period 20mS of PCA = 20ms/78.125us = 256 (CL Reload)
- CL (20mS) = 256 Cycle Auto Reload
- Load CCAPxH (1.0mS) = 256-13 = 243 (243,244,...,255 = 13 Cycle)
- Load CCAPxH (2.0mS) = 255-26 = 230 (230,231,...,255 = 26 Cycle)
Datasheet
- P89V51RD2 [pdf]
Source Code (For SDCC)
- pwm_servos.h
- test_servos.c
Related Links
- What is a Servo?
- Tutorial on how to modify a servo for full 360 degree rotation
- Servo Tutorial for Robotics
- Pulse-width modulation (Wiki)
- Introduction to Pulse Width Modulation (PWM)
EEPROMs Interfacing
24LC512 is a 64K x 8 (512 Kbit) Serial Electrically Erasable PROM (EEPROMs), from Microchip Technology Inc. (see the product page). It has been developed for advanced, low-power applications such as personal communications and data acquisition. This device also has a page write capability of up to 128 bytes of data.
This device is capable of both random and sequential reads up to the 512K boundary. Functional address lines allow up to eight devices on the same bus, for up to 4 Mbit address space.
This is an example how to interface 24XXX EEPROMs with 8051. I use SDCC as C Compiler. My schematic is shown below.
Schematic: 8051 interface to 24XXX EEPROMs
Datasheet
- 24LC512 [pdf]
Source Code (For SDCC)
- 24xx512.h
- test_eeprom.c
Related Links
-24LC512 Products Page
-Interfacing I2C EEPROM (24LC256) with MCS-51 (KEIL C51)
Saturday, September 9, 2006
Real Time Clock Interfacing
DS1307, a 64 x 8, Serial, I2C Real-Time Clock, is a low-power, full binary-coded decimal (BCD) clock/calendar plus 56 bytes of NV SRAM. Address and data are transferred serially through an I2C, bidirectional bus. The clock/calendar provides seconds, minutes, hours, day, date, month, and year information. It a product of Maxim/Dallas Semiconductor, see the product page.
This is an example how to interface DS1307 with 8051. I use SDCC as C Compiler. My schematic is shown below.
Schematic: 8051 interface to DS1307
Datasheet
- DS1307 [pdf]
Source Code (For SDCC)
- ds1307.h
- test_ds1307.c
Note: require lcd.h and i2c.h
Related Links
- DS1307 Products Page
- Interfacing I2C RTC (DS1307) with MCS-51 (KEIL C51)
I²C Bus Interfacing
Three speed modes are specified: Standard; 100kbps [Bits per Second], Fast mode; 400kbps, High speed mode 3.4Mbps. I2C, due to its two-wire nature (one clock, one data) can only communicate half-duplex. The maximum bus capacitance is 400pF, which sets the maximum number of devices on the bus and the maximum line length.
The interface uses 8 bit long bytes, MSB (Most Significant Bit) first, with each device having a unique address. Any device may be a Transmitter or Receiver, and a Master or Slave. The Slave is any device addressed by the Master. A system may have more than one Master, although only one may me active at any time.
Data and clock are sent from the Master: valid while the clock line is high. The link may have multiple Masters and Slaves on the bus, but only one Master may be active at any one time. Slaves may receive or transmit data to the master.
This is an example how to interface I²C with 8051. I use SDCC as C Compiler. My schematic is shown below. I set P2.6 as SCL and P2.7 as SDA.
Datasheet
I²C-Bus Specification [pdf]
Source Code (For SDCC)
- i2c.h
Note: see DS1307 and 24LC512 for applications
Related Links
- Philips I²C Bus
- I2C (Inter-Integrated Circuit) Bus Technical Overview and Frequently Asked Questions (FAQ)
- I²C Bus and Access Bus
- http://www.i2c-bus.org/
Friday, September 8, 2006
Analog-to-Digital Interfacing
The ADS7841 is a 4-channel, 12-bit sampling Analog-to-Digital Converter (ADC) with a synchronous serial interface. The resolution is programmable to either 8 bits or 12 bits. It is a product of Burr-Brown form Texas Instrument, see the product page.
This ADC give the 12-bit Binary Code Decimal (BCD) output value therefore the maximum value is 999 integer. If we want to convert this value to the real value, we must divide this value by 4096 (12-bit) and multiply by the maximum real ouput. Suppose the real maximum of output is 5V, the ratio should be 5/4096 = 0.00122. We can use 0.00122 multiply the output from ADS7841 to get the real ouput value.
This is an example how to interface ADS7841 with 8051. I use SDCC as C Compiler. My schematic is shown below. I still do not convert to the real value so my variables are integer.
Datasheet
- ADS7841 [pdf]
Source Code (For SDCC)
- ads7841.h
- test_ads7841.c
Note: require lcd.h
Related Links
- ADS7841 Products Page
Thursday, September 7, 2006
LCD interfacing
This is an example how to interface to the standard Hitachi-44780 LCD using an 8051 microcontroller and SDCC as C Compiler. I use a standard 16-character by 2-line LCD module, see schematic below. Here, I use 4-bit interfacing.
Source Code (For SDCC)
- lcd.h
- test_lcd.c
Related Links
- How to control a HD44780-based Character-LCD: The Industry Standard Character LCD
- Yet Another 8051-to-LCD Interface
- Interfacing: Converting 8-bit LCD communication to 4-bit
Tuesday, September 5, 2006
Installing MIDE-51 and SDCC and for Win32
This page is an installation guide for someone who are interested in developing 8051 microcontrllor with C-language. All of tools I selected are freeware or opensource with no limitation of number of lines of your code.
Contents
- Installing MIDE-51, Editor for 8051
- Installing SDCC, C Compiler for 8051
- Installing ASEM-51, Assembler for 8051
- Installing JSIM-51, Simulator for 8051
- Installing FlashMagic, ISP for Philips MPU
- Configuration
- Test
1. Installing MIDE-51
MIDE-51 is freeware Integrated Development Environment (IDE) for MCS-51 microcontroller. The full package already comes with:
Assembler : ASEM-51 by W.W.Heinz (v1.3)
C compiler : SDCC: Small Device C Compiler (v2.5.4)
Simulator : TS Controls 8051 Emulator v1.0 evaluation (Owner : http://www.tscontrols.com was gone)
Simulator : JSIM-51 Simulator by Jens Altmann (v4.05)
Just downloads midepack0258.exe and executes this file, everything will setup completely.
Feature on MIDE-51:
- Syntax highlighter on ASEM-51 reserved word & addition register on selected device (devices listed on ASEM51/MCU folder)
- Syntax highlighter on SDCC reserved word & MCS-51 standard register
- Support multi document workspace
- Support standard editor feature and shortcut key such as Cut , Copy, Paste, Find, Replace and Windows tile & cascade
- Editor font style and size selectable
- Save recent file(s) opened in list
- Shortcut to ASEM-51 html manual
- Shortcut to SDCC html & PDF manual (search file on SDCC/DOC)
- Report assembler & compiler message
- Support drag and drop file from explorer.
- Automatic save last windows position.
- Support wheel mouse
- Bookmark code position upto 10
- Show/Hide line number on editor
However, if you would like to use the newer version of them, you can also install each package manualy. First, downloads only editor version of MIDE-51 ( MIDE51_0258.zip) and extracts it to any directory (C:\MIDE51). You should have C:\MIDE51\MIDE51.EXE. For others package, please follow these instructions.
2. Installing SDCC
SDCC is a Freeware, retargettable, optimizing ANSI - C compiler that targets the Intel 8051, Maxim 80DS390, Zilog Z80 and the Motorola 68HC08 based MCUs. Work is in progress on supporting the Microchip PIC16 and PIC18 series. The entire source code for the compiler is distributed under GPL.
To install the SDCC, download the latest version from http://sdcc.sourceforge.net/snap.php#Windows (currently v2.6.x). SDCC are available for several different operating systems. I am working on a PC running Microsoft Windows XP therefore I download the win32 self-executing SDCC install file
(sdcc-20060818-4339-setup.exe) and run the executable. By default, it will install all files to C:\Program Files\SDCC, you also can change to any directory.
When finishing installing the program, a prompt will appear asking to add the directory containing the program binaries to your PATH. I also recommend you to download the SDCC documentation (sdcc-doc-20060818-4339.zip), and extract it to your SDCC documentation directory (C:\Program Files\SDCC\doc).
3. Installing ASEM-51
ASEM-51 is a two-pass macro assembler for the Intel MCS-51 family of microcontrollers. It is running on the PC under MS-DOS, Windows and Linux. The ASEM-51 assembly language is based on the standard Intel syntax, and implements conditional assembly, macros, and include file processing. The assembler can output object code in Intel-HEX or Intel OMF-51 format as well as a detailed list file. The ASEM-51 package includes support for more than 180 8051 derivatives, a bootstrap program for MCS-51 target boards, and documentation in ASCII and HTML format. And it is free ...
The simplest way of installing ASEM-51 is copying all files of the package to your working directory, and enjoy the benefits of true plug-and-play compatibility!. Alternatively, I have set it up on Windows XP manually:
- Downloads the lastest ASEM-51 for DOS/Windows (currently v1.3)
- Create a new, empty directory on your harddisk (C:\ASEM51).
- Unpack your ASEM-51 distribution archive into this directory, or copy all files of the ASEM-51 package into it.
- Make the scratch directory default, run the batch file INSTALL.BAT provided, and follow the instructions.
- Reboot your PC.
You can update MPU file by downloading http://plit.de/asem-51/mcufiles.zip.
4. Installing JSIM-51
JSIM-51 is a powerful software simulator for 8051 Microcontrollers and it's derivatives. The program simulates the processor kernel and some of the hardware functions. It was born due to all commercial products are too expensive for private users. It is free and opensource.
To install:
- Download 8051.zip ( DLL for simulation of a standard-8051 , V1.017 - 09/17/1998)
- Download 80320.zip ( DLL for simulation of a 80320 -Dallas , V1.019 - 10/03/2000)
- Download jsim_e.zip ( english version V4.05 from 01/08/2000)
Extract all files i.e., jsim.exe, 8051.dll and 80320.dll to your directory (C:\Jsim51).
5. Installing FlashMagic ISP Software
Flash Magic is a free, powerful, feature-rich Windows application that allows easy programming of Philips Flash Microcontrollers. Its function is to download compiled HEX file to your (Philips) microcontroller.
Please download and install the current version of FlashMagic.exe here.
6. Configuration
To combine every things:
- Execute MIDE-51.exe
- From menu bar, Edit-->Preference (F12)
- Click Tab C-Compiler, Edit your SDCC Path (C:\Program Files\SDCC)
- Click Tab Assembler, Edit your ASEM-51 Path (C:\ASEM51).
- Click Tab Simulaotr, Simulator Profile, select JSIM with 8051.dll, edit Execute file (Full path and filename) C:\JSIM51\jsim.exe.
- Now, everything is complete
7. Test
Execute MIDE-51.exe and File-->New (Ctrl+N), edit this code
#include <p89v51rd2.h>Save to anyname.c and then Build (F9). You will found many files in the directory, one of them is .HEX file which can be downloaded to your MCU by using FlashMagic. Or, you can simulate it by using Jsim51, Build and Sim (Shift+Ctrl+F9).
unsigned char i;
void main() {
i=10;
}
Note: I tested on my P89V51RD2 MPU. Enjoy your 8051 microcontroller.
Related Links
Product Page: http://www.semiconductors.philips.com/
Data Sheet: P89V51RB2_RC2_RD2-03.pdf
Boot Loader: p89v_lv51rd2_bl_upd_v5.zip
FlashMagic ISP Software: http://www.esacademy.com/
SDCC : http://sdcc.sourceforge.net/
MIDE-51 : http://www.opcube.com/home.html
ASEM-51 : http://plit.de/asem-51/home.htm
JSIM-51 : http://home.arcor.de/jensaltmann/jsim-e.htm
Monday, September 4, 2006
Introduction to SDCC: Small Device C Compiler
SDCC is a Freeware, retargettable, optimizing ANSI - C compiler that targets the Intel 8051, Maxim 80DS390, Zilog Z80 and the Motorola 68HC08 based MCUs. Work is in progress on supporting the Microchip PIC16 and PIC18 series. AVR and gbz80 ports are no longer maintained. The entire source code for the compiler is distributed under GPL.
Some of the features include:
- ASXXXX and ASLINK, a Freeware, retargettable assembler and linker.
- extensive MCU specific language extensions, allowing effective use of the underlying hardware.
- a host of standard optimizations such as global sub expression elimination, loop optimizations (loop invariant, strength reduction of induction variables and loop reversing ), constant folding and propagation, copy propagation, dead code elimination and jump tables for 'switch' statements.
- MCU specific optimisations, including a global register allocator.
- adaptable MCU specific backend that should be well suited for other 8 bit MCUs
- independent rule based peep hole optimizer.
- a full range of data types: char (8 bits, 1 byte), short (16 bits, 2 bytes), int (16 bits, 2 bytes), long (32 bit, 4 bytes) and float (4 byte IEEE).
- the ability to add inline assembler code anywhere in a function.
- the ability to report on the complexity of a function to help decide what should be re-written in assembler.
- a good selection of automated regression tests.
SDCC also comes with the source level debugger SDCDB, using the current version of Daniel's s51 simulator. (Currently not available on Win32 platforms).
SDCC was written by Sandeep Dutta and released under a GPL license. Since its initial release there have been numerous bug fixes and improvements. As of December 1999, the code was moved to SourceForge where all the "users turned developers" can access the same source tree. SDCC is constantly being updated with all the users' and developers' input.
SDCC Homepage
- http://sdcc.sourceforge.net/
Sunday, September 3, 2006
Philips P89V51RD2 Microcontroller
I am using Philips P89V51RD2 as 8051 Microcontroller Unit (MCU). And I have been developing my code with Opensouce C Compiler SDCC. Please visit my Tools page for software preparation guides.
The P89V51RD2 is a 80C51 microcontroller with 64 kB Flash and 1024 bytes of data RAM. A key feature of the P89V51RD2 is its X2 mode option. The design engineer can choose to run the application with the conventional 80C51 clock rate (12 clocks per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput at the same clock frequency. Another way to benefit from this feature is to keep the same performance by reducing the clock frequency by half, thus dramatically reducing the EMI.
The Flash program memory supports both parallel programming and in serial In-System Programming (ISP). Parallel programming mode offers gang-programming at high speed, reducing programming costs and time to market. ISP allows a device to be reprogrammed in the end product under software control. The capability to field/update the application firmware makes a wide range of applications possible.
The P89V51RD2 is also In-Application Programmable (IAP), allowing the Flash program memory to be reconfigured even while the application is running.
Features
- 80C51 Central Processing Unit
- 5 V Operating voltage from 0 MHz to 40 MHz
- 64 kB of on-chip Flash user code memory with ISP (In-System Programming) and IAP (In-Application Programming)
- Supports 12-clock (default) or 6-clock mode selection via software or ISP
- SPI (Serial Peripheral Interface) and enhanced UART
- PCA (Programmable Counter Array) with PWM and Capture/Compare functions
- Four 8-bit I/O ports with three high-current Port 1 pins (16 mA each)
- Three 16-bit timers/counters
- Programmable watchdog timer
- Eight interrupt sources with four priority levels
- Second DPTR register
- Low EMI mode (ALE inhibit)
- TTL- and CMOS-compatible logic levels
- Brown-out detection
- Low power modes
o Power-down mode with external interrupt wake-up
o Idle mode - DIP40 packages
Related Links
Product Page: http://www.semiconductors.philips.com/
Data Sheet: P89V51RB2_RC2_RD2-03.pdf
Boot Loader: p89v_lv51rd2_bl_upd_v5.zip
FlashMagic ISP Software: http://www.esacademy.com/
Saturday, September 2, 2006
Introduction to 8051 Microcontroller
The 8051 is an 8 bit microcontroller originally developed by Intel in
1980. It is the world's most popular microcontroller core, made by
many independent manufacturers (truly multi-sourced). There were 126
million 8051s (and variants) shipped in 1993!!
A typical 8051 contains:
- CPU with boolean processor
- 5 or 6 interrupts:
2 are external
2 priority levels - 2 or 3 16-bit timer/counters
- programmable full-duplex serial port
(baud rate provided by one of the timers) - 32 I/O lines (four 8-bit ports)
- RAM
- ROM/EPROM in some models
One strong point of the 8051 is the way it handles interrupts.
Vectoring to fixed 8-byte areas is convenient and efficient. Most
interrupt routines are very short (or at least they should be), and
generally can fit into the 8-byte area. Of course if your interrupt
routine is longer, you can still jump to the appropriate routine from
within the 8 byte interrupt region.
The 8051 instruction set is optimized for the one-bit operations so
often desired in real-world, real-time control applications. The
boolean processor provides direct support for bit manipulation. This
leads to more efficient programs that need to deal with binary input
and output conditions inherent in digital-control problems. Bit
addressing can be used for test pin monitoring or program control
flags.
See full information from 8051 FAQ
- http://www.faqs.org/faqs/microcontroller-faq/8051/