at89s4051 Tools - Page 1
Forum section: electronics / general

author: meerweten
author_rank: Contributor
timestamp: January 12, 2014, 07:37:50 pm
content: Hey all,a few day's ago i got my hand on some at89s4051's but i never used them before and don't seem to be able to find the proper software to write the code, compile it and program the damned chip.i was thinking about using just a texteditor for writing my code (as i like to use linux for programming and not windows, but i have both).for the programming i was thinking of using avrdude but it seems that doesn't support my chipdoes anyone have some software, info i can use?Meerweten

author: Bored@Work
author_rank: Super Contributor
timestamp: January 12, 2014, 07:51:43 pm
content: It don't think that MCU is really worth the effort. It has an 8051 compatible CPU, so you'd have to look for a 8051 compiler (many available) and find compatible header files for that particular MCU. Then you need to find ISP software for it. And maybe the worst, you have to get the software running, it might be for an ancient version of Windows, depending if that MCU is obsolete or not (I didn't check). And you need a compatible programming adapter/cable for the MCU and ISP software.

author: Alana
author_rank: Frequent Contributor
timestamp: January 12, 2014, 07:54:29 pm
content: Bascom 8051 supports that chip and you can write in assembly language as well as basic. Programer STK200 clone - i know it needs LPT but...

author: SeanB
author_rank: Super Contributor
timestamp: January 12, 2014, 08:13:11 pm
content: Supported by the Minipro programmer, so usable. There is a thread here about using and how the programmer works. Does a lot of other programmable devices as well.

author: dannyf
author_rank: Super Contributor
timestamp: January 12, 2014, 10:05:18 pm
content: QuoteKeil has probably the most widely used compiler / ide for that. A programmer can be had for a few dollars.It is a good chip to learn on.

author: meerweten
author_rank: Contributor
timestamp: January 14, 2014, 08:11:54 pm
content: thanks,i think keil will be the best solution, only thing i need to find then is a proper include file

author: Koustrup
author_rank: Newbie
timestamp: January 20, 2014, 07:57:52 am
content: Hi meerweten.http://sdcc.sourceforge.netis your friend. It is a free 8051 compiler (and other architectures as well).I'we used it for At89C2051 (only differens is the amount of flash, if I recall corectly).The benefit of using Keil is the simulator. So I'we used it for low level drivers and developed the main application using the SDCC.To include the headerfile, just do:#include <at89x051.h>Another great information page is:http://www.8052.com

author: meerweten
author_rank: Contributor
timestamp: January 22, 2014, 07:24:54 pm
content: Quote from: Bored@Work on January 12, 2014, 07:51:43 pmyes maybe the 8051's are a little old and yes there are many other newer chips that might be better,there are 2 reasons why i choice this:the first is that i could get a few chips for a good price (only shipping costs)and i wanted to learn other chips than the pic's i've been using for a while and the arduino's (atmega328/atmega8/atmega32/atmega126).Quote from: KoustrupHa thanks Koustrup!!

author: Bored@Work
author_rank: Super Contributor
timestamp: January 22, 2014, 09:08:55 pm
content: Quote from: meerweten on January 22, 2014, 07:24:54 pmEhm, you did recognize that that particular MCU has 256 byte, yes bytes, of RAM? Not exactly fun to program.

author: abyrvalg
author_rank: Frequent Contributor
timestamp: January 23, 2014, 12:34:40 am
content: 128 bytes actually. But it has just 4K of flash also, so it's pretty adequate, small MCU for simple tasks and pure asm programming. For example Atmega128 has the same 1:32 RAM:ROM ratio.

author: lapm
author_rank: Frequent Contributor
timestamp: January 23, 2014, 07:58:16 am
content: Personally id say go for it... Learn it. What you learn usually makes you better in future since you do develop better understanding on how different architectures in mcu works.. And experience you gain is making learning something else in future easier.if you deal with industrial control systems, door automation, etc... There is good chance you might run into 8051 variant in those. At least in factory i work in those are everywhere, if its not run PLC, it probably has 8051 in it...

author: amyk
author_rank: Super Contributor
timestamp: January 23, 2014, 09:47:01 am
content: 8051 is one of those MCUs you almost never hear about in the Western hobbyist community (they're a lot more popular in China and India) but they're everywhere - every PC keyboard controller also has an 8051-derivative in it, and so do MP3 players, LCD monitors, laptop ECs,clones of Apple lightning cables, cheap (and overpriced) logic analysers, soldering and hot air rework stations, etc...

author: meerweten
author_rank: Contributor
timestamp: January 23, 2014, 08:10:19 pm
content: another reason to learn how to use them.

author: dannyf
author_rank: Super Contributor
timestamp: January 23, 2014, 08:51:23 pm
content: Agreed. I enjoyed getting more out of small chips.

author: abyrvalg
author_rank: Frequent Contributor
timestamp: January 23, 2014, 09:34:41 pm
content: 250 MHz 8051 inside (PS2251-03)

author: dannyf
author_rank: Super Contributor
timestamp: January 23, 2014, 09:55:56 pm
content: 8051 I think has the largest installed base of all mcus.

author: JoeN
author_rank: Frequent Contributor
timestamp: January 25, 2014, 08:33:28 am
content: I see this chip is supported by the ChipMax2, the programmer I used for an Atmel 89C2051.https://www.eetools.com/index.cfm?fuseaction=product.display&product_ID=303If the ChipMax2 supports it, probably a bunch of other out-of-system ROM programmers like this do too.For my 8051 project I used this:http://en.wikipedia.org/wiki/MCU_8051_IDEFree, and it supports your chip.For all the complaints about this chip being old, feeble, hard to program, worries about having to use an LPT port (wrong), and other tales of disaster in this thread so far, it took me about 4-6 hours to get it working, no prior knowledge, and was not at all hard.Code:#include <8051.h>int state = 0;int pattern = 1;volatile depressed = 0;void delay(){int i, j;for(i=0; i<25; i++) {for(j=0; j<256; j++) {if ((depressed==0) && ((P1 & 16) == 16)){depressed = 1;pattern ++ ;if (pattern > 3)pattern = 0;}if ((depressed==1) && ((P1 & 16) == 0)){depressed = 0;}}}}int main(){while(1){state++;if (pattern == 0){if (state > 4)state = 0;P3 = 0b10111111; // Set P3.P1 |= 0b00001100; // set bits 2,3 in P1switch(state){case 0:P3 &= 0b10101111; // enable LED 4break;case 1:P3 &= 0b10010111; // enable LED 5,3break;case 2:P3 &= 0b00111011; // enable LED 6,2break;case 3:P3 &= 0b10111101; // enable LED 7,1P1 &= 0b11111011;break;case 4:P3 &= 0b10111110; // enable LED 8,0P1 &= 0b11110111;break;}}if (pattern == 1){if (state > 7)state = 0;P3 = 0b10111111; // Set P3.P1 |= 0b00001100; // set bits 2,3 in P1switch(state){case 0:P3 &= 0b10101111; // enable LED 4break;case 1:case 7:P3 &= 0b10010111; // enable LED 5,3break;case 2:case 6:P3 &= 0b00111011; // enable LED 6,2break;case 3:case 5:P3 &= 0b10111101; // enable LED 7,1P1 &= 0b11111011;break;case 4:P3 &= 0b10111110; // enable LED 8,0P1 &= 0b11110111;break;}}if (pattern == 2){if (state > 4)state = 0;P3 = 0; // Clear P3.P1 &= 0b11110011; // clear bits 2,3 in P1switch(state){case 0:P3 |= 0b00010000; // disable LED 4break;case 1:P3 |= 0b00101000; // disable LED 5,3break;case 2:P3 |= 0b10000100; // disable LED 6,2break;case 3:P3 |= 0b00000010; // disable LED 7,1P1 |= 0b00000100;break;case 4:P3 |= 0b00000001; // disable LED 8,0P1 |= 0b00001000;break;}}if (pattern == 3){if (state > 7)state = 0;P3 = 0; // Clear P3.P1 &= 0b11110011; // clear bits 2,3 in P1switch(state){case 0:P3 |= 0b00010000; // disable LED 4break;case 1:case 7:P3 |= 0b00101000; // disable LED 5,3break;case 2:case 6:P3 |= 0b10000100; // disable LED 6,2break;case 3:case 5:P3 |= 0b00000010; // disable LED 7,1P1 |= 0b00000100;break;case 4:P3 |= 0b00000001; // disable LED 8,0P1 |= 0b00001000;break;}}delay();}}Here, I pulled it out of the project box. Click below.

author: dannyf
author_rank: Super Contributor
timestamp: January 25, 2014, 11:42:48 am
content: If it is an atmel chip, many of those cheap USB avr programmers work on them too.

author: dannyf
author_rank: Super Contributor
timestamp: January 25, 2014, 11:49:07 am
content: -P3 = 0b10111111; // Set P3.-one suggestion: don't hard code them like that. For example, if you port the code to a different chip or change port assignment, you have to manually change all those statements.instead, you can define for example LED1PORT to be P3, and in your code operate on LED1PORT.this makes porting and debugging much easier.

author: nctnico
author_rank: Super Contributor
timestamp: January 25, 2014, 12:29:37 pm
content: Quote from: dannyf on January 23, 2014, 09:55:56 pmI'd guess the 8042 (which isn't an 8051!). AFAIK there is one is each PC keyboard and probably inside the PC as well.Either way the 8051 is an archaic architecture which deserves to be forgotten. Programming it using C results in slow programs. The only advantage is that it can be used without paying royalties so it can be economic to use in high volume products.