microcontroller programming -- how to begin

May 25, 2006 123 Replies

Hmmm... that was my impression as well, that the AVR is more like a rethought PIC than a rethought 8051.

One source of confusion is that Atmel made some 8051 derivatives just before they introduced the AVR. Some AVR programmers even have 8051s in them to do the communication with the host.

The fact that the 8051 core has been around since 1980 simply proves how damn good it is.

Of course it works. It has to be the most successful uC ever.

You actually *want* to use the sledgehammer of C to program a uC ? Good Lord ! That's the first time I've heard anyone propose dropping a processor on that account.

Graham

In article , mc wrote: [...]

They look quite alike:

They are both little chips with a bunch of legs around the outside.

On chip stuff is controlled by writes into a special section of the address space.

They have 8 bit registers.

Seperate code vs data address spaces

The only real ones are that AVRs are a single makers product and that there is less free stuff out there for it.

-- kensmith@rahul.net forging knowledge

So they have a Harvard architecture. Does that distinguish them from PIC or a bunch of others?

Right; or more free stuff depending on your point of view. Single-maker chips are very attentively supported by their makers. There's a lot of free

8051 stuff but it is old and DOS-based (as far as I know).

Hello Graham,

was a

It was a freebie. You wouldn't want to wear that thing but you could do all kinds of stuff with it.

The EZ430 was a freebie as well this year although most participants already had bought these. Very cool. But I go there to ask questions, mostly. You also get a glimpse into the future on stuff that isn't released anywhere, not even on their web site. Like the new 430F5xxx devices with wireless on board. I am especially looking forward to that version with sub-GHz wireless.

Regards, Joerg http://www.analogconsultants.com

Hello Graham,

It sure is. And multi-sourced. That fact alone sells a whole lot of chips.

Yep, it's the VW Beetle of uCs. Somehow I always ended up with the

80C51, mostly because everyone knows it and it's 2nd sourced.

No big deal these days. Modern compilers generate quite small code size with it. Of course, realtime stuff is a different matter.

Regards, Joerg http://www.analogconsultants.com

It's nothing like a PIC, either. It has a decent set of 32 registers and compilers for it are easy to write, there are lots of them including gcc.Someone has just ported ADA to it! I''ve tried it and it seems to work OK.

Leon

Why particularly sub-GHz?

Apparently TI bought up a Scandanavian company to get all that technology instantly.

Best regards, Spehro Pefhany

"it\'s the network..." "The Journey is the reward" speff@interlog.com Info for manufacturers: http://www.trexon.com Embedded software/hardware/analog Info for designers: http://www.speff.com

Hello Spehro,

The main reason for me is that there are more low data rate applications below a GHz and the devices are also usually cheaper. When I asked they said it'll go down to around 400Mhz. No idea why that lower limit but we'll see when they come out with the F5 series.

2.4GHz has the advantage of being quite international but it becomes crowdy up there. Less range, too.
Regards, Joerg http://www.analogconsultants.com

Just be careful. That eon can easily become an eternity when the micro hangs. If 1/20th of a second is your critical window before things can go bzzzt then that might be a good limit for the watchdog timer. IOW it should be a lot shorter than that.

Regards, Joerg http://www.analogconsultants.com

!

It wasn't code size that bothered me. It was the idea that someone would dismiss an

8051 on the basis of wanting to program it in C !

Graham

Yes, I think that the first thing in my main loop should be "sanity checks". Shut down unless several conditions are true. Etc.

i

To paraphrase what Knuth said about Pascal (about 15 yrs. ago), the 8051 is everybody's second-favorite CPU. They differ as to most favorite, but nobody really *dislikes* the 8051. It's the old reliable...

Hello Graham,

dismiss an

Actually, my very first 8051 design was programmed in C.

Regards, Joerg

formatting link

I dislike it, but have used it many times and wouldn't hesitate again. It has a *very* ugly ISA but has rather nice assortment of hardware available.

Keith

You don't like the instruction set ? Use a high level language then. I love using PL/M 51 actually, it's a breeze.

Graham

chips.

using

I used PL/M on 80186's many moons ago. It's a good choice, but I prefer assembler for hardware as weird as the 8051. I didn't see any HLL as much of an advantage for the things I did with 8051s.

Keith

using

No ? Code maintenance is one good reason for starters ( e.g. esp if someone else has to do the maintenance ).

I've done stuff in PL/M that I seriously reckon you'd be hard pressed to even keep track of in assembler ( like variable lifetimes for example ). When it generates ~30k of object code I'd like to see that written in assembler.

Graham

No, it doesn't, but does make it like the 8051 which was the question.

No, simply more.

OH! BOY! is that ever BS! Examples:

Philips' and then Xilinx's support for the 5V Cool Runner series.

Almost any single supplyer's low power CMOS RAM.

Intel's 8089 I'm sure every designer that has been around for a while has a horror story or two about the lack of support for a single maker's product.

Does it work? Yes. Is some of it have a point a drool UI? Yes again. Is there a lot of free stuff? Yes.

-- kensmith@rahul.net forging knowledge

love using

else has to

There is nothing about assembler that is inherently unmaintainable. One can write crap in any language.

keep

generates ~30k

BTDT. The crypto key storage unit I did in the early '90s used two

8051s (one secured one to run the blinkin' lights) with a lot more code in it than that. Well written (and commented) assembler isn't a big deal to keep track of. I've seen a *lot* of HLL code that seemed to be intentionally obscure. "Hey, it was hard to write, it _should_ be hard to read."
Keith

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required