Thinking about migrating from 8051

Thread Starter

cmartinez

Joined Jan 17, 2007
8,218
I've been using and programming 8051 controllers for decades now, and although they're still being updated by some manufacturers (to the point of making them single-cycle devices, and with in-system programming and other features), and can still handle a lot of complicated tasks, I'm giving serious consideration to learning how to use a recent model that is not constrained to an 8-bit architecture. This is mainly because of maximum code size, the lack of higher than 8-bit functions and registers, and the speed at which they run, which is a bit limited compared to newer technologies. The model that I'm most familiar with is the AT89LP4052, although I've used other atmel 32 pin devices before.

I'm not attracted to arduino nor raspberry, since (although they seem powerful) I consider those devices to be too high end for what I intend to use them for.
I've been programming in assembly all my life, and I'm no big fan of C. This is because most of my applications are time-critical, and I have to know exactly what instruction is being performed at the MCU at all times.
So far I'm considering ARM and AVR as possible substitutes for the 8051. What do you think? Which device that you are familiar with would you recommend for me to start learning, considering that I intend to program it using assembly? Also, it must have at least one UART port. And USB capability would be nice, but not essential.
 

MrChips

Joined Oct 2, 2009
30,701
I have literally written thousands of lines of code in ASM for both HC11/HC12 and AVR. I rate both architectures highly.
 

jjw

Joined Dec 24, 2013
823
You don't want to program ARM in assembler.

You may want to look at Atmel AVR, Freescale and NXP.

(NXP is taking over Freescale.)
What is wrong with ARM assembly programming ?
I have looked some introductory texts and it looks easy enough.
 

MrChips

Joined Oct 2, 2009
30,701
What is wrong with ARM assembly programming ?
I have looked some introductory texts and it looks easy enough.
Besides, the C compiler can do a lot better job at compiling/assembling the code than I can do in assembler.

Here is a screen shot of STM ARM disassembly of a simple Delay( ) software function.
See if you can decode what the ASM code is doing.


 

jjw

Joined Dec 24, 2013
823
Besides, the C compiler can do a lot better job at compiling/assembling the code than I can do in assembler.

Here is a screen shot of STM ARM disassembly of a simple Delay( ) software function.
See if you can decode what the ASM code is doing.


Ok, must be some compiler overhead , but writing the delay function in asm should'nt take more than a few instructions.
 

MrChips

Joined Oct 2, 2009
30,701
In AVR, HC11 or MSP430 I can write a delay function with two asm instructions (not including the input and exit instructions).
And anyone familiar with asm code ought to be able to figure out the code.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,218
Ok, this is what I'm used to when working with the AT89LP4052:
  • I/O pins can be configured as open-collector, quasi-bi, inputs, push-pull outputs
  • 1 UART
  • watchdog timer
  • low power mode
  • external interrupts
  • SPI
  • 2.5 to 5.5V operation
For me, the most important points would be the configurable I/O's and the UART

Does AVR provide these features, and perhaps more?

EDIT: the AT89LP4052 also has in-system programming and two PWM outputs
 
Last edited:

MrChips

Joined Oct 2, 2009
30,701
How much SRAM, flash and EEPROM do you need?
How many I/O pins do you need?
Package and number of pins?
Clock speed?
XTAL or internal clock operation?
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,218
How much SRAM, flash and EEPROM do you need?
How many I/O pins do you need?
Package and number of pins?
Clock speed?
XTAL or internal clock operation?
What I'd like is:
  • At least 16-bit addition, subtraction and multiplication, plus 16-bit indirect addressing
  • Number of I/O pins should be at least 15 or 16
  • Package is not important as long as it can be mounted on a socket, and is not smt.
  • Flash should be greater than say, 256K
  • SRAM of at least 32K
  • EEPROM of 32K too would be nice
  • Clock speed greater than 22 Mhz (considering single-cycle instructions)
  • Preferably xtal or external oscillator operation, so I can choose whatever operating frequency I like
And while you're at it... I'd also like a pony, a unicorn and a flying dragon for Christmas :D
 

josip

Joined Mar 6, 2014
67

RamaD

Joined Dec 4, 2009
328
Silabs 8 bit microcontrollers - upto 100MHz., internal clock, more timers, ADC, DAC, etc.
Maybe, flash is limited to 128k & RAM to 8k.
Wizard to configure your timers, io, pwms, uart, etc.,
8051 core uC and give you a free KEIL compiler, SDCC can also be used. Learning curve is reduced.

These days, C compilers have become very efficient. So, better alternative could be to use C, and any time critical areas can be replaced with assembler, after having a look at assembler listing (of C program).
 

takao21203

Joined Apr 28, 2012
3,702
What I'd like is:
  • At least 16-bit addition, subtraction and multiplication, plus 16-bit indirect addressing
  • Number of I/O pins should be at least 15 or 16
  • Package is not important as long as it can be mounted on a socket, and is not smt.
  • Flash should be greater than say, 256K
  • SRAM of at least 32K
  • EEPROM of 32K too would be nice
  • Clock speed greater than 22 Mhz (considering single-cycle instructions)
  • Preferably xtal or external oscillator operation, so I can choose whatever operating frequency I like
And while you're at it... I'd also like a pony, a unicorn and a flying dragon for Christmas :D
No prob, what do you prefer, DHL, EMS, UPS or HKEP? Comes in eco-friendly corrugated + coated cardboard from sustainable sources (such as your local shops or neighbourhood dump from a factory). XXXL box no prob either the Boeing 747 will drop your new toys over your house with a parachute.

Seriously, writing assembler becomes a pain even on 18F PIC.
OK you play super high school musical wizard- take a horse drawn cart, and 8 small bicycles, and give local high school students a source of income. Imagine that on a 4-lane motorway all day?

I believe I had sufficient.

Inclusive a small pianola playing cool tunes from a large brass disc + ejecting small free ice creams randomly.

No prob in assembler, you have to in order your programs do something meaningful, fast, and compact.

1 year later, you wont be able to understand it again yourself.

Its called code rot. seriously. The time it takes you to think into it again + make changes, the C programmer has rewritten it anew and has gone home already.

<lamentation ENDS>
 

takao21203

Joined Apr 28, 2012
3,702
Silabs 8 bit microcontrollers - upto 100MHz., internal clock, more timers, ADC, DAC, etc.
Maybe, flash is limited to 128k & RAM to 8k.
Wizard to configure your timers, io, pwms, uart, etc.,
8051 core uC and give you a free KEIL compiler, SDCC can also be used. Learning curve is reduced.

These days, C compilers have become very efficient. So, better alternative could be to use C, and any time critical areas can be replaced with assembler, after having a look at assembler listing (of C program).
Not good either, optimizing the C source can improve by factor 10 and more.
If thats not enough, get a chip with suitable pheripherals, more RAM, DMA, more MHz, unroll loops and so on.

Assembler is useful insofar you can see how the C source correlates to the functional model of the MCU and its instruction set, often only need to look at a few kinds of opcodes.

ARM isnt much suitable to look at each assembler instruction and get at least a gist out of it whats happening.
 

atferrari

Joined Jan 6, 2004
4,764
Hola César,

Started with the Z80 and used it for maybe 3 years. Then used briefly 8051 ones including Tiny Basic (first minimal one was running in 20 minutes!.

From there to the PIC 16C57 (my first valid project - temperature data collector/display for a greenhouse), then the 16F, and finally, the 18F family, always in Assembler with which I feel quite comfortable.

With this last, 18F family, I implemented, dual signal generators, on-screen text for analog scopes (including on/off z axis control on a character basis), FIR filter, Conway's "LIFE" game on an LCD screen, LEDs cube and some I cannot recall now. A dual polarity, digitally controlled power supply was stopped because I could not solve problems in the analog part of it. My bad.

Right now, tidying up the on-screen text to show it in internet and then I will start looking for THE project, to move on. Maybe moving to the 24F family but not sure.
 
Last edited:

takao21203

Joined Apr 28, 2012
3,702
Been there, first tried 68000 while in college, where we were exposed to 8085 and 8086 too.
Found it quite difficult at this time.

Later really learned 8086/80386 + wrote some real programs. Its comfortable once you get used to segments.

Then started with 16F PICs early 2000s.

Abandoned assembler when starting with USB. How could you code FAT file system for SD card in assembler? Its quite tedious and lengthy in C.
 
Top