<html><head></head><body>The timer method runs inside the clock tick ISR and you can't call printf() from an interrupt. At least that is what I spot first.<br>
<br>
Also easy in C++ to do something in an ISR you shouldn't.<br><br><div class="gmail_quote">On September 15, 2014 3:05:03 PM CDT, "Martínez, Pablo" <pabloa.mar@gmail.com> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div dir="ltr"><div><div>Hi guys,<br /><br /></div>Im trying to implement a single shot timer.<br /><br /></div>I derive from rtemsTimer class and replace virtual void triggered()=0<br /><br /><div>#include <rtems++/rtemsTimer.h><br />...<br /><br />class Timer : public rtemsTimer {<br />public:<br /> Timer(const char* tname);<br /> virtual ~Timer();<br />private:<br /> void triggered();<br />};<br /><br /></div><div>in timer.cpp<br /></div><div><br />void SynchTimer::triggered(){<br /><br /> printf("hello Timer! \n");<br /><br />}<br /><br /><br /></div><div>Then I have the following task class who creates and fires a Timer object:<br /><br />class TimerMngr : public rtemsTask{<br /><br />public:<br /> TimerMngr(const char* tname);<br /> virtual ~TimerMngr();<br /><br />private:<br /> void body(rtems_task_argument argument);<br /><br />};<br /></div><div><br /><br /></div><div>in timerMngr.cpp<br /><br
/>TimerMngr::TimerMngr(const char* tname)<br />: rtemsTask(tname,<br /> 1,<br /> RTEMS_MINIMUM_STACK_SIZE,<br /> RTEMS_PREEMPT|RTEMS_TIMESLICE,<br /> 0,<br /> RTEMS_NO_FLOATING_POINT,<br /> RTEMS_LOCAL)<br /><br />{<br /> if(last_status_code()!=RTEMS_SUCCESSFUL)<br /> printf("SynchMngr::error when create()%d \n",<br /> last_status_code());<br />}<br /></div><div><div><div><br /><br /><br />void TimerMngr::body(rtems_task_argument argument){<br /><br /> printf("TimerMngr::body! \n"); [1] <br /><br /> /* Create the Timer<br /> * *****************************/<br /> Timer* timer=new Timer("timer");<br /><br /> printf("SynchMngr, CurrentTime! @ %d \n",getCurrentTime()); [2] <br /><br /><br /> /* start timer<br /> * *****************************/<br />
rtems_status_code status;<br /> status=synch_timer->fire_after(120);<br /> printf("synch_timer->fire_after() status %d \n",status); [3] <br /><br /><br /> wake_after(500);<br /> printf("SynchMngr, CurrentTime @ %d \n",getCurrentTime()); [4]<br /><br />}<br /><br clear="all" />unsigned TimerMngr::getCurrentTime(){<br /> //rtems_unsigned32 time_stamp;<br /> unsigned time_stamp;<br /> time_stamp=0;<br /> rtems_status_code status;<br /><br /> status=rtems_clock_get(RTEMS_CLOCK_GET_SECONDS_SINCE_EPOCH,&time_stamp);<br /> if(status!=RTEMS_SUCCESSFUL)<br /> printf("error with rtems_clock_get %d \n",status);<br /><br /> return time_stamp;<br />}<br /><br /></div><div>When I run the app I get the first and second printf [1] y [2]. But just <br />"syn" from the 3erd printf [3].<br /><br /></div><div>In the conf file:<br /><br />#define
CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER<br />#define CONFIGURE_TICKS_PER_TIMESLICE 30 <br />#define CONFIGURE_MAXIMUM_TIMERS 4<br /></div><div><br /></div><div>Any suggestion?<br /></div><div><br /></div><div>Cheers,<br /></div><div>Pablo<br /></div><div></div></div></div></div></blockquote></div></body></html>