Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Best language for learning AVRs (was forth)

2006-02-09 by Mike Perks

Chuck Hackett wrote:

> I guess I'd agree with Tom that assembler forces you to KNOW your hardware
> environment better which is a good thing.  But, just because one is 
> using a
> higher level language like C doesn't relieve you from having to know 
> quite a lot
> about the hardware - assuming you're interacting with the world 
> outside the chip
> which is the point in microcontrollers.
>
> For the beginner you have to have a deeper understanding of the 
> hardware, etc.
> before you can get your first "Hello World" program working: stack 
> management,
> processor initialization, etc., etc.  Heck, in microcontrollers you 
> have to
> understand how to manage a UART/USART before you'll see the "Hello 
> World".  But
> Then again, I guess the microcontroller equivalent of "Hello World" is 
> to blink
> an LED which does make things easier <g>.

Ok good, now we can get some debate going. I know in the end we will 
agree to disagree but I would to present some other cases that you may 
not be aware of.  It is true that even for programming in C for AVRs you 
need to worry about things like clock frequencies, UBRR registers for 
baud rates, I/O ports and registers etc etc

Now suppose you had a programming environment that abstracts all of 
these details and gives you a large function library to do serial I/O, 
blink an LED and send "hello world" to a console connected over a serial 
port. Here is a simple program:
    Sub Main()
        Console.WriteLine("Hello World!")
        Do
            Call PutPin(D.7, 1)
            Call Sleep(0.1)  ' IEEE single-precision floating point 
number support
            Call PutPin(D.7, 0)
            Call Sleep(0.1)
        Loop
    End Sub

The program prints "Hello World!" to COM1 and blinks a LED at 5Hz. No 
stack management, no manipulation of the UART, no processor 
initialization etc. This program was written using the ZX-24 chip that I 
mentioned before (http://www.zbasic.net/ ). The equivalent code in C (or 
ASM) even using a function library like AVRLibC is harder to create, 
download and debug. As I hinted before ZBasic has a large function 
library that covers everything from SPI, I2C to datatype conversions to 
InputCapture and ShiftIn to Multitasking.

I started with microprocessors using ZBasic (and its competitor BasicX) 
and now I moving into learning more AVR-C and assembler. This path makes 
sense for me and I would think a lot of beginners because as we have 
said before, it hides a lot of the details and allows you to get a 
program going so much more quickly. Coming at it from the other 
direction, it can also allow you to prototype an idea very quickly and 
easily without getting buried in the programming. Of course there are 
exceptions such as high frequency DDS waveform synthesis which needs 
total control and assembler code to achieve the best results.

I have an article on my website that is an Introduction to ZBasic and 
compares it to C, ASM and other programming architectures. On my 
projects page I have a complete description for a recently completed 
AVR-based Metronome project.

Mike
http://home.austin.rr.com/perks/micros/Articles/
http://home.austin.rr.com/perks/micros/Projects/

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.