comp.lang.ada
 help / color / mirror / Atom feed
* Trouble with Timers on the ARM
@ 2014-08-13  6:24 williamjthomas7777
  2014-08-13 16:53 ` Mike Silva
  0 siblings, 1 reply; 4+ messages in thread
From: williamjthomas7777 @ 2014-08-13  6:24 UTC (permalink / raw)


I'm using the latest GNAT ARM Elf download (Windows) with the STM32F4 Discovery Board.

The code ends up spinning in the last chance handler (the code generates an exception). The code runs on the Windows x86 native compiler fine.

Am I missing something special that has to be done on the ARM target or with the ARM RTS?

-------------

with Last_Chance_Handler;  pragma Unreferenced (Last_Chance_Handler);
with System;

with Timer_Pack;

procedure Timer_Main is
   pragma Priority (System.Priority'First);
begin
   Timer_Pack.Set_Timer;
   loop
      null;
   end loop;
end Timer_Main;

-------------

with Ada.Real_Time.Timing_Events; use Ada.Real_Time.Timing_Events;

package Timer_Pack is

  procedure Set_Timer;

   protected The_Timer is
     procedure The_Callback ( Event : in out Timing_Event );
   private
     State   : Boolean := False;
   end The_Timer;

end Timer_Pack;

------------

with Ada.Real_Time; use Ada.Real_Time;

package body Timer_Pack is

   The_Event : Timing_Event;
   R1        : constant Integer := 500;

   procedure Set_Timer is
   begin
     Set_Handler
       (The_Event,
        Clock+Milliseconds(R1),
        The_Timer.The_Callback'Access);
   end Set_Timer;

   protected body The_Timer is

     procedure The_Callback ( Event : in out Timing_Event ) is
     begin
       State := not State;
       Set_Handler
         (Event,
          Clock+Milliseconds(R1),
          The_Timer.The_Callback'Access);
     end The_Callback;

   end The_Timer;

end Timer_Pack;

------------

with System;

package Last_Chance_Handler is

   procedure Last_Chance_Handler (Msg : System.Address; Line : Integer);
   pragma Export (C, Last_Chance_Handler, "__gnat_last_chance_handler");
   pragma No_Return (Last_Chance_Handler);

end Last_Chance_Handler;

------------

package body Last_Chance_Handler is

   procedure Last_Chance_Handler (Msg : System.Address; Line : Integer) is
      pragma Unreferenced (Msg, Line);
   begin
      --  No return procedure.
      pragma Warnings (Off, "*rewritten as loop");
      <<spin>> goto spin;   -- yes, a goto!
      pragma Warnings (On, "*rewritten as loop");
   end Last_Chance_Handler;

end Last_Chance_Handler;

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-08-17 19:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-13  6:24 Trouble with Timers on the ARM williamjthomas7777
2014-08-13 16:53 ` Mike Silva
2014-08-17  4:43   ` William Thomas
2014-08-17 19:51     ` Mike Silva

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