微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 硬件工程师文库 > 使用ADSP-CM408F ADC控制器的电机控制反馈采样时序

使用ADSP-CM408F ADC控制器的电机控制反馈采样时序

时间:07-26 来源:未知 点击:

Q_MEMORY];

  55. static ADI_TRU_HANDLE hTru;

  /*TRU Device Memory and Handle*/

  /*************Function Prototypes****************/

  56. void SetupADC(void);

  57. void SetupTRU(void);

  58. static void AdccTmr0Callback(void *pCBParam, uint32_t Event, void *pArg);

  59. static void AdccTmr1Callback(void *pCBParam, uint32_t Event, void *pArg);

  /******Function to Configure ADCC***************/

  60. void SetupADC(void) {

  61. static ADI_ADCC_RESULT result;

  /*Set Up Event Configuration Table*/

  62. ADI_ADCC_EVENT_CFG EventCFG[NO_OF_EVENTS] = {

  63. {0, ES_CTL, ADI_ADCC_ADCIF0, ADI_ADCC_TIMER0, true, 0, SMP_TIME0},

  64. {1, EC_CTL, ADI_ADCC_ADCIF1, ADI_ADCC_TIMER0, true, 2, SMP_TIME1},

  65. {2, VDC_CTL, ADI_ADCC_ADCIF0, ADI_ADCC_TIMER0, false, 4, SMP_TIME2 },

  66. {3, THS_CTL, ADI_ADCC_ADCIF0, ADI_ADCC_TIMER0, false, 6, SMP_TIME3 },

  67. {4, IV_CTL, ADI_ADCC_ADCIF0, ADI_ADCC_TIMER1, true, 8, SMP_TIME4 },

  68. {5, IW_CTL, ADI_ADCC_ADCIF1, ADI_ADCC_TIMER1, true, 10, SMP_TIME5 }}; /*Event#, CTL_WORD, ADC Interface, Timer ID, sim. samp, Mem offset in frame, Event time */

  P16

  /*ADCC Setup API Functions*/

  69. result = adi_adcc_OpenDevice(ADCC_DEVICE_NUM, ADCCMemory, &hADCC);

  70. result = adi_adcc_OpenTimer(hADCC, ADI_ADCC_TIMER0, ADCCTmr0Memory, &hADCCTimer0);

  71. result = adi_adcc_OpenTimer(hADCC, ADI_ADCC_TIMER1, ADCCTmr1Memory, &hADCCTimer1); /* ADCC Device handle, Timer to open, Timer memory, Pointer to the timer handle */

  72. result = adi_adcc_RegisterTmrCallback (hADCCTimer0, AdccTmr0Callback, hADCCTimer0);

  73. result = adi_adcc_RegisterTmrCallback (hADCCTimer1, AdccTmr1Callback, hADCCTimer1);/*Register callback functions*/

  74. result = adi_adcc_EnableDMAMode(hADCC,true);

  75. result = adi_adcc_ConfigADCCClock(hADCC, ADI_ADCC_ADCIF0, false,1u, 8u);

  76. result = adi_adcc_ConfigADCCClock(hADCC, ADI_ADCC_ADCIF1, false,1u, 8u ); /*For each ADC interface: ADCC handle, ADC Interface number, falling edge, ACLK Clock divide, NCK*/

  77. result = adi_adcc_ConfigChipSelect(hADCC, ADI_ADCC_ADCIF0, false, 1u, 0u, 9);

  78. result = adi_adcc_ConfigChipSelect(hADCC, ADI_ADCC_ADCIF1, false, 1u, 0u, 9);/*For each interface: ADCC handle, ADC interface, active low, TCSCK, TCKCS, TCSCS*/

  79. result = adi_adcc_ConfigTimer(hADCCTimer0, ADI_ADCC_TRIG0, true, false);

  80. result = adi_adcc_ConfigTimer(hADCCTimer1, ADI_ADCC_TRIG0, true, false); /*For each timer: Timer handle, Timer trigger source, falling edge trigger, No trigger output */

  81. result = adi_adcc_ConfigEvent(hADCC, &EventCFG[0], NO_OF_EVENTS); /*ADCC handle, Pointer to the event configuration table, Number of events in the table */

  82. result = adi_adcc_SetEventMask(hADCC, EVENT_MASK); /* Handle to the device, Enable all events */

  83. adi_adcc_EnableDualBitDataIF(hADCC, true); /*Dual bit interface allows highest throughput*/

  84. memset((void *)SampleBuffer0, 0, NUM_SAMPLES0 * sizeof(short));

  85. memset((void *) SampleBuffer1, 0, NUM_SAMPLES1 * sizeof(short));

  86. result = adi_adcc_SubmitBuffer(hADCCTimer0, SampleBuffer0, FRAME_INC0, FRAMES_IN_BUFFER);

  87. result = adi_adcc_SubmitBuffer(hADCCTimer1, SampleBuffer1, FRAME_INC1, FRAMES_IN_BUFFER);

  /*For each timer: timer handle, Pointer to the buffer, Frame increment, Number of frames that fits into the given buffer */

  88. result = adi_adcc_EnableTimer(hADCCTimer0, true);

  89. result = adi_adcc_EnableTimer(hADCCTimer1, true);

  90. result = adi_adcc_EnableDevice(hADCC, true);

  /*Enable everything*/

  91. }

  /*******Function to Configure TRU****************/

92. void Se

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top