<div dir="auto"><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Jul 8, 2017 10:09 AM, "Denis Obrezkov" <<a href="mailto:denisobrezkov@gmail.com">denisobrezkov@gmail.com</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello all,<div>I worked with local interrupts last few days and found some strange behavior:</div><div><p style="margin-top:0px;font-family:Roboto;font-size:14px"><br></p><p style="margin-top:0px;font-family:Roboto;font-size:14px">I am trying to handle local interrupts.<br>That's what I do, in my handler for timer interrupts:<br>* disable timer interrupts in mie<br>* read a current value from mtime<br>* copy it to mtimecmp (both are 64bit width types)<br>* add some big value to mtimecmp<br>* enable timer interrupts in mie.</p><p style="font-family:Roboto;font-size:14px">And I have two boards and the problem is that on one of them interrupts are permanently generated because mip register is always 1 in mtip position, though mtimecmp is greater than mtime, and are not generated at all on the other.</p></div></div></blockquote></div></div></div><div dir="auto">Is there a procedure for clearing the interrupt? </div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><p style="font-family:Roboto;font-size:14px">In this piece of code, I turn on interrupts:<br>la t0, RISCV_Exception_default<br>csrs mtvec, t0<br>li t0, 0x88<br>csrs mie, t0<br>csrsi mstatus, 0x8</p></div></div></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">Can you point us to the documentation and section where this timer behavior is defined? Sometimes having someone else read it can provide a different interpretation.</div><div dir="auto"><br></div><div dir="auto">And is there other code like Linux which deals with this timer? There may be a magic sequence you are missing </div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><p><font face="Roboto"><span style="font-size:14px">My start file:</span></font><br><a href="https://github.com/embeddedden/rtems-riscv/blob/hifive1/c/src/lib/libbsp/riscv32/hifive1/start/start.S" target="_blank">https://github.com/<wbr>embeddedden/rtems-riscv/blob/<wbr>hifive1/c/src/lib/libbsp/<wbr>riscv32/hifive1/start/start.S</a><br></p><p><font face="Roboto"><span style="font-size:14px">and ISR:</span></font><br><a href="https://github.com/embeddedden/rtems-riscv/blob/hifive1/c/src/lib/libbsp/riscv32/hifive1/irq/irq.c" target="_blank">https://github.com/<wbr>embeddedden/rtems-riscv/blob/<wbr>hifive1/c/src/lib/libbsp/<wbr>riscv32/hifive1/irq/irq.c</a><br></p><p><br></p><p>I also posted this question here:</p><p><a href="https://forums.sifive.com/t/how-to-deal-with-local-interrupts-in-hifive1/632" target="_blank">https://forums.sifive.com/t/<wbr>how-to-deal-with-local-<wbr>interrupts-in-hifive1/632</a><font color="#888888"><br></font></p><font color="#888888"><div><br></div>-- <br><div class="m_-7944153673088393300gmail_signature">Regards, Denis Obrezkov</div>
</font></div></div>
</blockquote></div><br></div></div></div>