comp.lang.ada
 help / color / mirror / Atom feed
From: rolf.ebert@gmx.net (Rolf Ebert)
Subject: GNAT (gcc-3.3) on AVR microcontrolers, need help for compiler debugging
Date: 18 Nov 2002 02:28:44 -0800
Date: 2002-11-18T10:28:44+00:00	[thread overview]
Message-ID: <d2b11234.0211180228.52df30d7@posting.google.com> (raw)

I have managed to get my first Ada program running on an AVR
microcontroler just tonight!  I simply reads out the keys pressed and
shows the corresponding LEDs on my STK-500 board.

pragma No_Run_Time;
with Avr.IO;              use AVR.IO;

procedure SwitchLed is
   Port_B_In_Addr  : constant IO_Address := 16#16#;
   Port_B_DDR_Addr : constant IO_Address := 16#17#;
   Port_D_Out_Addr : constant IO_Address := 16#12#;
   Port_D_DDR_Addr : constant IO_Address := 16#11#;
begin
   -- set port B as input
   Set_IO(IO_Reg => Port_B_DDR_Addr, Value => 16#FF#);
   -- set port D as output
   Set_IO(IO_Reg => Port_D_DDR_Addr, Value => 16#00#);

   loop
      Set_IO(IO_Reg => Port_D_Out_Addr,
             Value  => Get_IO(IO_Reg => Port_B_In_Addr));
   end loop;
end SwitchLed;

The above program translates to just five assembler instructions (with
full optimization and no run time checks)!

The easy part was the setup of a cross-compiler on Linux/GNU, although
it took me quite some time to find a working set of gcc, binutil, and
libc sources.  Eventually I now have a more or less working gnat1 and
gnatbind for AVR.  If anybody cares, I can make the binaries
available.

The difficult part (at least for me) was to figure out how to pass
literal addresses (for the IO-ports) to the corresponding assembler
code without crashing the compiler or the assembler (you actually have
to inline the assembler routines and must not compile the body where
they are programmed).

Anyway, I now need a helping hand who knows a bit about the GNAT
internals.  The compiler dies quite often (e.g. when using Integer,
when not inlining assembler code, sometimes when compiling child
units, etc).  I'd like to get at least some of them fixed.

Who is willing to exchange some email with me and point me to
interessing locations in the GNAT sources?

TIA

    Rolf

P.S. This is just a hobbyist project.  I shall not invest any money
and only some limited time.



             reply	other threads:[~2002-11-18 10:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-18 10:28 Rolf Ebert [this message]
2002-11-18 16:14 ` GNAT (gcc-3.3) on AVR microcontrolers, need help for compiler debugging Bernd Trog
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox