Cypress技术论坛
直播中

李微波

7年用户 902经验值
私信 关注
[问答]

怎么将8位计数器值传送到VDAC

你好,
我正在开发一个简单的应用程序,在UDB我有一个计数器设计。计数器值写入状态寄存器。
我有一个DMA,它由CPUY-Req触发,它将8位计数器值传送到VDAC。在VDAC的输出应该是锯齿波。然而,我并没有得到同样的结果。当我用计时器触发DMA-Req和计数器时,我能得到锯齿波。有人能帮我吗?以下是我的主要.c文件
{包含& lt;H.& gt;空主({)UtiT8通道;UIT8TD;αIF(定义(α-C51))//信道=DMAYD-主化(1, 1, 0,0);信道=DMAYD-主化(0, 0, 0,0);α-Tor//信道=DMAYD-主化(1, 1,Hi16(StasuSugReStStxReGuiStasuSug Reg),Hi16(VDAC8VIDAC88xD));HANNEL=DMAYDMANITIV化(0, 0,HI16(StasuSugReStStxReGuiStasuSug Reg),HI16(VDAC8VIDAC88*d));(1){Td=CydMatalLoad();如果(TD)!} CydMatdStCad配置(TD,1,TD,0);CydMatdStVald(TD,Lo16((UTI32)StutsSuxReStSyrGeStasuSug Reg),Lo16((UTIT32)VDAC8VIDAC88*D));CyDmaChSetInitialTd(通道,TD);CyDmaChPriority(通道,0);CyDmaChEnable(通道,1);CyDmaChSetRequest(Chhanne)我cpu_req);timer_start();vdac8_start();为(;;){ // vdac8_setvalue(status_reg_read());/*把您的应用程序代码在这里。*/}
}
当做
梅茨

以上来自于百度翻译


     以下为原文
  Hi,
    I am developing a simple application where I have a counter design in UDB. The counter value is written into a status register.
    I have a DMA which is triggered by CPU_REQ , which transfers the 8 bit counter value to the VDAC. The output  at the VDAC  should be  a saw tooth wave. However I am not gettin the same. When I use a Timer to trigger the DMA req as well as the counter, I am able to get the sawtooth wave. Could anybody please help me with this. Following is my main.c file
     
    #include

void main()
{    uint8 channel;
      uint8 td;

   

      
         #if (defined(__C51__))              
         //  channel = DMA_DmaInitialize(1, 1, 0, 0);
           channel = DMA_DmaInitialize(0, 0, 0, 0);
        #else
          // channel = DMA_DmaInitialize(1, 1, HI16(Status_Reg_sts_reg__STATUS_REG), HI16(VDAC8_viDAC8__D) );
       channel = DMA_DmaInitialize(0, 0, HI16(Status_Reg_sts_reg__STATUS_REG), HI16(VDAC8_viDAC8__D) );
        #endif  

     while(1){        
             td=CyDmaTdAllocate();
         if(td!=DMA_INVALID_TD)
           break;
           }  
        CyDmaTdSetConfiguration(td, 1, td,0 );
        CyDmaTdSetAddress(td, LO16((uint32)Status_Reg_sts_reg__STATUS_REG), LO16((uint32)VDAC8_viDAC8__D) );      
        CyDmaChSetInitialTd(channel, td);                     

        CyDmaChPriority(channel,0);
        CyDmaChEnable(channel, 1);
        CyDmaChSetRequest(channel, CPU_REQ);
        Timer_Start();   
      VDAC8_Start();
      
     for(;;)
     {
//     VDAC8_SetValue(Status_Reg_Read());
         /* Place your application code here. */
     }
    }
     
    Regards
    meenz

回帖(13)

马昱

2019-4-26 10:10:46
嘿,Meenz,你使用的是基于UDB的计数器,还是使用组件创建工具建立了自定义计数器组件?

以上来自于百度翻译


     以下为原文
  Hey Meenz, are you using UDB based Counter or built a Custom Counter component using component creation tool?
举报

李微波

2019-4-26 10:27:14
Hi-DASG
我已经在UDB中实现了计数器。这是一个简单的实验,通过DMA对UDB的访问进行实验。
IAM附加归档的项目。你能否告诉我,我是否需要做什么特别的工作?
当做
梅茨
UDB2DAC.BangLe01.Zip
959.1 K

以上来自于百度翻译


     以下为原文
  Hi dasg
    I have implemented the counter in UDB. It was a simple experiment to experiment the access of UDB via DMA
    I am attaching the archived project . Could you please tell me if I have to make any specific DMA setiings
     
    Regards
    meenz


举报

李微波

2019-4-26 10:40:15
此外,我附上工程定时器产生的请求。
当做
梅茨
UDB2DAC.BangLe02.Zip
959.1 K

以上来自于百度翻译


     以下为原文
  Also, I am attaching the project with Timer generating the request.
     
    Regards
    meenz


举报

郭雨桐

2019-4-26 10:51:11
当使用相同的时钟触发DMA和计数器(在这种情况下,定时器)时,DMA和计数器按输入时钟确定的速率工作。因此,每个增量计数从计数器有效地转移的DMA。DMA只占用一个总线时钟周期。
然而,当DMA在CPU中被触发时,您可能会连续触发它,并且每个传输在一个总线时钟周期结束。计数器按计时器确定的速率递增。因此,从状态寄存器转移到DAC的值将是不规则的。在每一个CPU触发之后,可能需要等到计数器被初始化,然后进入下一步。我希望这有帮助!

以上来自于百度翻译


     以下为原文
  
        
  • When you trigger the DMA and the counter using same clock(in this case, a Timer), DMA and the counter operates at the rate determined by input clock. Hence every incremental count from the counter is effectively transferred by DMA. DMA takes only one BUS CLOCK cycle.    
     
   
        
  • However, when the DMA is trigger in CPU, you might be triggering it continuously and each transfer finishes in one BUS Clock period. The counter increments at the rate determined by the Timer. Hence the values transferred from the status register to DAC will be irregular. After every CPU trigger it might be necessary to wait until the counter has incermented and then move on to the next step.   
    I hope this helps !
举报

更多回帖

发帖
×
20
完善资料,
赚取积分