1 Reply Latest reply on Oct 24, 2011 12:30 AM by udayan.umapathi

    Read timer FIFO use DMA

    morar.konstantin

      Hello i am new with the psoc and have a problem.

         

      I am using a timer to capture the time between two rising edges. After the second edge occur the timer generate a interrupt signal on the interrupt Output. This signal i am using to start the DMA Transfer. With the DMA i want to get the captured Values at the Timer FIFO. My problem is that i get only one Value. My design and code are below.

         

      #include <device.h>

         

      uint8 fifo_resynchtimer_dma_Chan;
      uint8 fifo_resynchtimer_dma_TD[1];
      bit resynch_flag=0;
      uint16 synch_timer_captured[2];
      uint16 period_synch=0;
      #define fifo_resynchtimer_dma_BYTES_PER_BURST 4
      #define fifo_resynchtimer_dma_REQUEST_PER_BURST 1
      #define fifo_resynchtimer_dma_SRC_BASE (CYDEV_SRAM_BASE)
      #define fifo_resynchtimer_dma_DST_BASE (CYDEV_SRAM_BASE)
      void main()
      {
       CYGlobalIntEnable;
       synch_gen_Start();
       resynch_timer_Start();
       isr_period_capture_Start();
       lcd_Start();

         

       fifo_resynchtimer_dma_Chan = fifo_resynchtimer_dma_DmaInitialize(fifo_resynchtimer_dma_BYTES_PER_BURST, fifo_resynchtimer_dma_REQUEST_PER_BURST,
        HI16(fifo_resynchtimer_dma_SRC_BASE), HI16(fifo_resynchtimer_dma_DST_BASE));
       fifo_resynchtimer_dma_TD[0] = CyDmaTdAllocate();
       CyDmaTdSetConfiguration(fifo_resynchtimer_dma_TD[0], 2, fifo_resynchtimer_dma_TD[0], TD_SWAP_EN | fifo_resynchtimer_dma__TD_TERMOUT_EN | TD_INC_SRC_ADR | TD_INC_DST_ADR);
       CyDmaTdSetAddress(fifo_resynchtimer_dma_TD[0], LO16((uint32)resynch_timer_CAPTURE_LSB_PTR), LO16((uint32)&synch_timer_captured[0]));
       CyDmaChSetInitialTd(fifo_resynchtimer_dma_Chan, fifo_resynchtimer_dma_TD[0]);
       CyDmaChEnable(fifo_resynchtimer_dma_Chan, 1);

         

          for(;;)
          {
       if (resynch_flag)
       {
        resynch_flag=0; //resynch flag is set in the isr_period_capture
        
       }
       lcd_Position(0,0);
       lcd_PrintInt16(synch_timer_captured[0]);
       lcd_Position(1,0);
       lcd_PrintInt16(synch_timer_captured[1]);
       lcd_Position(0,8);
       lcd_PrintInt16(synch_timer_ReadPeriod());
          }
      }