<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Hi Richard,<br>
<br>
another hint: Using printf inside interrupts is not always
supported in RTEMS...<br>
wkr,<br>
<br>
Thomas.<br>
<br>
Am 30.08.2017 um 16:07 schrieb <a class="moz-txt-link-abbreviated" href="mailto:Richard.Glossop@L3T.com">Richard.Glossop@L3T.com</a>:<br>
</div>
<blockquote type="cite"
cite="mid:4D2D43B41F7EB245AB1826F7B05BE023E1796DA2@ISSCINSV-N714.iss.l-3com.com">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal">Want to change the source of RTEMS time
tick interrupt from Timer 0 on the LEON to a GPIO pin. Have
had success enabling the GPIO pin for the interrupt source (I
get Spurious Interrupt 5 messages on the gdb console – we are
using GPIO 5 – this tells me the interrupt is happening).
When I try to use rtems_interrupt_catch to install a new
vector isr for the GPIO, the system crashes.
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Here is the code:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New"">rtems_isr_entry
reMapRealTimeInterrupt (void)<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New"">{<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""> int level;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New"">
rtems_isr_entry old_handler;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New"">
rtems_status_code retVal;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New"">
<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New"">
rtems_interrupt_disable (level); // disable all maskable
interrupts<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""> retVal =
rtems_interrupt_catch( // re-map vector 5 to our
handler (GPIO 5)
<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""> handler,<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New"">
5,
<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New"">
&old_handler);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New"">
printf("Remap retVal:0x%x\n",retVal);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""> *(unsigned
int*)TIMCTR1 &= ~0x00000009; // disable timer 1
interrupt enable and timer enable<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""> *(unsigned
int*)IMR &= ~0x00000040; // mask interrupt for timer
1 interrupt since it is no longer used<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""> *(unsigned
int*)IMR |= 0x00000020; // enable GPIO 5 interrupt in
IMR<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""> *(unsigned
int*)ILR |= 0x00000020; // set interrupt 5 to be a
level 1 interrupt<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""> *(unsigned
int*)GPIOIMR |= 0x00000020; // enable bit 5 to cause
interrupts (GPIO 5)<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""> *(unsigned
int*)GPIOIER |= 0x00000020; // set GPIO interrupt 5 to be
edge triggered<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""> *(unsigned
int*)GPIOIPR |= 0x00000020; // set GPIO interrupt 5 to be
rising edge<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New"">
<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""> rtems_interrupt_enable
(level); // enable all previously enabled interrupts<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""> return
old_handler; // return original isr
address in case want to restore<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New"">}<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""> rtems_isr
handler (rtems_vector_number vector)<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""> {<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New"">
printf("This is irq %d.\n",vector);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New"">
rtems_clock_tick();<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New"">
<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""> }<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal">Can anyone help with this, or point me to
example code to accomplish the same thing?<o:p></o:p></p>
</div>
<span style="font-size: 14px; font-family: "Times New
Roman";"><br>
Effective immediately my new email address is <span
style="color:#0000FF"><a class="moz-txt-link-abbreviated" href="mailto:Richard.Glossop@L3T.com">Richard.Glossop@L3T.com</a></span>. Please
update your records.</span><span style="font-size: 14px;"></span>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@rtems.org">users@rtems.org</a>
<a class="moz-txt-link-freetext" href="http://lists.rtems.org/mailman/listinfo/users">http://lists.rtems.org/mailman/listinfo/users</a></pre>
</blockquote>
<p><br>
</p>
<pre class="moz-signature" cols="72">--
IMD Ingenieurbuero fuer Microcomputertechnik
Thomas Doerfler Herbststrasse 8
D-82178 Puchheim Germany
email: <a class="moz-txt-link-abbreviated" href="mailto:Thomas.Doerfler@imd-systems.de">Thomas.Doerfler@imd-systems.de</a>
PGP public key available on request</pre>
</body>
</html>