<div dir="ltr"><div><div>Hi,<br><br></div>using an external pin to directly trigger an interrupt is a little bit tricky and you will probably need to do some signal conditioning according to the expected shape and nature of the input signal that would appear on the pin. Did you already consider all this? <br></div>If not then this is where you should start from: study your input signal, look for a suitable digital signal conditioning for it (I suppose you are using one of the LEON development boards so you can put such circuit on chip with LEON as it is a soft-core already), then get the interrupt pin of LEON connected to the output from that signal conditioning circuit (rather than directly from the gpio pin, which should be connected as the input for this signal conditioning).<br><div class="gmail_extra"><br clear="all">
<br><div class="gmail_quote">On Wed, Aug 30, 2017 at 4:07 PM, <span dir="ltr"><<a href="mailto:Richard.Glossop@l3t.com" target="_blank">Richard.Glossop@l3t.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div link="#0563C1" vlink="#954F72" lang="EN-US">
<div class="m_-8059064847766583842m_419595163492372627WordSection1">
<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.
<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Here is the code:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New"">rtems_isr_entry reMapRealTimeInterrupt (void)<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New"">{<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""> int level;<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""> rtems_isr_entry old_handler;<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""> rtems_status_code retVal;<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New"">
<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""> rtems_interrupt_disable (level); // disable all maskable interrupts<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""><u></u> <u></u></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)
<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""> handler,<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""> 5,
<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""> &old_handler);<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""> printf("Remap retVal:0x%x\n",retVal);<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""><u></u> <u></u></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<u></u><u></u></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<u></u><u></u></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<u></u><u></u></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<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""><u></u> <u></u></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)<u></u><u></u></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<u></u><u></u></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<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New"">
<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""> rtems_interrupt_enable (level); // enable all previously enabled interrupts<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""><u></u> <u></u></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<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New"">}<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""> rtems_isr handler (rtems_vector_number vector)<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""> {<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""> printf("This is irq %d.\n",vector);<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""> rtems_clock_tick();<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New"">
<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""> }<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal">Can anyone help with this, or point me to example code to accomplish the same thing?<u></u><u></u></p>
</div>
<span style="font-size:14px;font-family:"Times New Roman""><br>Effective immediately my new email address is <span style="color:#0000ff">Richard.Glossop@L3T.com</span>. Please update your records.</span><span style="font-size:14px"></span>
</div>
<br>______________________________<wbr>_________________<br>
users mailing list<br>
<a href="mailto:users@rtems.org" target="_blank">users@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman<wbr>/listinfo/users</a><br></blockquote></div><br></div></div>