On 2006-03-16, Kris Heidenstrom <k...@abbey.co.nz> wrote:
> Chris Liechti wrote:
>
> [... why is SREG preserved over even a short interrupt handler?...]
>
>> I have no clue, but it could be that the processor uses segmented 
>> memory, and that __SREG__ selects the page with the memory
>> mapped peripherals?

It's because SREG is altered by the exclusive-or instruction,
so it needs to be saved and restored.  The AVR doesn't
save/restore the status register automatically as part of the
interrupt service/return sequence.  Because the status register
isn't really a CPU register, you have to load it from I/O or
memory space into a register before you can push it.

>> Everything is so much cleaner on the MSP430 except for the
>> MSP430's lack of a TX holding register empty flag and lack
>> of a TX shift register empty interrupt.  At least Atmel got that
>> right in the AVR ATmega parts.
>
> The MSP430 does have a transmit complete flag,

I know.  I said it didn't have a TX holding register empty
flag.

> it's called TXEPT and it's in UxCTL. You're right it doesn't
> have a transmit complete interrupt, the AVR is good in that
> respect.

The AVR has both flag and interrupt for TX holding register
empty and for TX shift register empty.  The MSP430 has an
interrupt for the former (but no flag), and a flag for the
latter (but no interrupt). It makes using the '430 UARTs a
pretty clumsy in some applications.

> I think the huge interrupt function size is due to the
> prologue and epilogue code in the interrupt handler. Looking
> at the problem as an assembly language programmer, you can see
> most

It can be trivially reduced from 18 instructions to 12 (which
is what the IAR compiler emits).  The AVR gcc code generator
just doesn't do a good job with the ISR prolog epilog.

> of it isn't needed for your simple example, but I doubt
> the compiler has that level of insight.

Yes, it does.  The compiler knows which registers are used in
the ISR and which ones aren't.  That's why the '430 version
didn't push/pop any registers.  Note that even the AVR version
doesn't save the entire register. Saving/restoring only the
minimum required set of registers in a prolog/epilog has been
SOP in compilers for decades.  The gcc AVR code generator just
doesn't do it right.  There was absolutely no reasons to
save/clear/restore the "zero" register, and it should have used
either r24 or r25 instead of the "temp" register when it was
saving/restore SREG.

>> And AVR parts are _expensive_.  I honestly don't see why
>> they're popular at all...
>
> I guess they're a good "first microcontroller" for beginners and
> students. They're available in DIP packages, you can build your
> own programmer, and the basic development tools are free.
> None of those things are true of the MSP430, though I'd readily
> admit that the MSP430 is a much nicer device in almost all
> respects.

Until you hit the 60K code space limit or need an external bus,
I think the '430 is definitely the winner.

> I think Atmel realise the benefit of providing an architecture
> that is easy to start working with. New programmers feel
> comfortable with it, and carry that familiarity and experience
> into their first job, so they will choose the AVR architecture
> if that is feasible. A viral marketing approach, I guess :-)
>
> I think the MSP430 is aimed more at the experienced
> developers, who don't mind paying for tools

I found tools for the MSP430 to be far cheaper than for AVR.  A
development board and JTAG interface from AVR runs about $500.
The same thing is $99 from TI or $50 from Olimex.

> because their cost is small compared to the money involved
> with a volume design, and the benefits of a C-friendly
> architecture have a clear and significant value.

-- 
Grant Edwards                   grante             Yow!  I have many CHARTS
                                  at               and DIAGRAMS...
                               visi.com            


Reply via email to