乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      [RTOS Support] Interrupt handling in FreeRTOS

       迎風(fēng)初開 2014-02-25

      FreeRTOS Support Archive

      The FreeRTOS support forum is used to obtain support directly from Real Time Engineers Ltd.

      This is a read only archive of threads posted to the FreeRTOS support forum. The archive is updated every week, so will not always contain the very latest posts.

      Use these archive pages to search previous posts. Use the "Live FreeRTOS Forum" link to reply to a post, or start a new support thread.




      Interrupt handling in FreeRTOS

      Posted by Bart on June 6, 2010
      Hi,

      I'm wondering if there is a special mechanism for handling
      interrupts in FreeRTOS? I wanted to write a simple interrupt
      routine that would toggle a led when I press a button. But sadly,
      when I add the interrupt initialization code, the task won't start.
      Here's the code:


      void initInterr()
      {
      AT91F_AIC_ConfigureIt(AT91C_BASE_AIC, AT91C_ID_PIOA, 5, AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL,ChangeFlashRate);
      AT91F_AIC_EnableIt(AT91C_BASE_AIC, AT91C_ID_PIOA);
      AT91C_BASE_PIOA->PIO_IER = AT91C_PIO_PA19; // B1
      }


      void vStartLEDFlashTasks()
      {
      initInterr();
      xTaskCreate( vLEDBlink, ( signed char * ) "LEDtaskC", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 2, NULL );

      }



      void ChangeFlashRate()
      {
      int status;
      status = AT91C_BASE_PIOA->PIO_ISR;
      vParTestToggleLED( 0 );
      }



      As you can see it's very simple. I'm using SAM7-P64 dev board. Am i doing it wrong?

      RE: Interrupt handling in FreeRTOS

      Posted by Bart on June 6, 2010
      It seems like the line :


      AT91C_BASE_PIOA->PIO_IER = AT91C_PIO_PA19;


      is the problem. If I comment it, the task is running and everything is ok. How should I handle the interrupt then?

      RE: Interrupt handling in FreeRTOS

      Posted by Rohit Grover on June 6, 2010
      Try enabling your interrupt only after the freeRTOS scheduler gets started.
      In your FreeRTOS port, isn't there a sample serial driver using interrupts which can help as a reference?

      RE: Interrupt handling in FreeRTOS

      Posted by Bart on June 8, 2010
      Hi, I bought the manual and changed my code, but interrupts still don't work. Everything seems to be ok. Is the ISR written correctly?


      void ToggleLedISR()
      {
      int status;
      static portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;

      status = AT91C_BASE_PIOA->PIO_ISR;
      xSemaphoreGiveFromISR(xSemafor, &xHigherPriorityTaskWoken);

      if(xHigherPriorityTaskWoken == pdTRUE) {
      AT91C_BASE_AIC->AIC_EOICR = 0xFA;
      portYIELD_FROM_ISR();
      }


      }


      Here's the task that takes the semaphore:




      void ToggleLedTask(void *pvParameters) {


      while(1) {
      xSemaphoreTake(xSemafor, portMAX_DELAY);

      vParTestToggleLED( 0 );

      }
      }


      RE: Interrupt handling in FreeRTOS

      Posted by Richard Damon on June 8, 2010
      Not familiar with this processor, but the line
      AT91C_BASE_AIC->AIC_EOICR = 0xFA;
      would be my guess at the error. I presume this is an end of interrupt control, and probably doesn't want to be conditioned on xHigherPriorityTaskWoken. I would suggest placing it before the if statement.

      RE: Interrupt handling in FreeRTOS

      Posted by Bart on June 8, 2010
      I got it working. It seems that an interrupt handler that gives a token to a semaphore needs to be called from a wrapper that copies the context. I got it working with:


      void vLed_ISR_Wrapper( void )
      {
      /* Save the context of the interrupted task. */
      portSAVE_CONTEXT();

      /* Call the handler itself. This must be a separate function as it uses
      the stack. */
      __asm volatile ("bl vLed_ISR_Handler");

      /* Restore the context of the task that is going to
      execute next. This might not be the same as the originally
      interrupted task.*/
      portRESTORE_CONTEXT();
      }


      Now, correct me if I'm wrong, but that is the only way I managed to get it done. Without the wrapper the processor "hangs" itself. And of course both the wrapper and the handler must be compiled in ARM mode. Or is there a way without using a wrapper?

      RE: Interrupt handling in FreeRTOS

      Posted by Richard on June 8, 2010
      If your interrupt is wanting to cause a context switch, or wanting to call a FreeRTOS API function, then the wrapper is required - as per the documentation and examples.

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請遵守用戶 評(píng)論公約

        類似文章 更多