Yahoo Groups archive

AVR-Chat

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

Message

RE: [AVR-Chat] *sigh*

2007-01-04 by larry barello

Believe me when I say I feel your pain in getting started, but also believe
me: The tools and the processor are not buggy.  They really do work as the
data sheet says. 

I consider myself a fairly advanced AVR programmer in both C and ASM.   Of
all the times I have been stumped by something and finally started to
conclude there was a problem in the processor, I have always, ALWAYS, found
it to be my own mistake.  There are definitely bugs in the AVR chips, but I
have never actually run across one in my own code.  Still it is wise to keep
up on the errata sheets for the chip you are using.

The tools are a different story: sometimes the Atmel tools can be a
nightmare, but mostly they work as advertised - just make sure you review
the errata before charging off.

-- my plug for using C compilers ---

"First get it working, then optimize." 

All compilers have code generation issues.  But, in response to the C code
generation issue: who cares?  If writing and debugging in C goes 10x faster
and allows the coder to visualize and code more effective algorithms and
makes it easy to abstract the algorithms so they can be used in more places,
then the resulting application will be smaller and faster than the
equivalent assembly code - and be more correct and be done sooner.  Once the
program is working, then, if necessary, one can go back and look for
optimizations.  Something that is difficult to do with assembly code.  

There have been times, I'll admit, when I find it faster to write a small
routine in asm rather than torture the C compiler to do what I want - that
is why it is always good to have a working knowledge of the underlying
machine architecture in embedded projects.  But those times are getting
pretty scarce in my work.

The only problem I have with C is that it is too easy to add functionality
to a project...

Cheers!

-----Original Message-----
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf
Of Thomas Keller
Sent: Thursday, January 04, 2007 7:18 AM
To: AVR-Chat@yahoogroups.com
Subject: Re: [AVR-Chat] *sigh*

    Ah.    A real world example of the mysterious lpm instruction. Now I 
see how that is used.  Thanks, David.


David VanHorn wrote:
>
> On 1/3/07, Thomas Keller <tjkeller1@alltel.net 
> <mailto:tjkeller1%40alltel.net>> wrote:
>
> > Well, I was under the impression that data HAD to be in EEPROM or RAM.
> > How woudl you address it if it is in the code space?
>
> Table: .db $00, $01.....
>
> Read_Table: ; called with offset in TEMP, output in TEMP
> clr R0 ; Trashes R0
> ldi ZL,low(table*2) ;Point at the table
> ldi ZH,high(Table*2)
> add ZL,TEMP ;Add the offset
> adc ZH,R0 ;16 bit add
> lpm ;On smaller AVRs the result is in R0, in larger ones it's
> mov TEMP,R0 ;lpm TEMP
>
>



 
Yahoo! Groups Links

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.