BF506F AD7266

Hi,

  I am working on a relatively simple program that converts an analog input into a duty cycle for an amplifier project.  I am still really new at DSP programming so I started with the AD7266_and_ACM example project for the BF506f ez-kit lite.  However, I am struggling to modify the project so that the ADC is continuously polling.  I have tried implementing  a loop to get the next buffer.

The code I added is as follows:

while(foo){

     result = adi_ad7266_IsBufferAvailable(hDevice, &bAvailable);

             CheckResult(result);

          if (bAvailable)

             {

               result = adi_ad7266_GetBuffer(hDevice, (void **)&pBuffer);

               CheckResult(result);

                     if (pBuffer){

                                   printf("%i\n",*pBuffer);

                         }

             }

     }

Using printf as debug statements, I have determined that the GetBuffer command is throwing back SPORT_FAILURE.

Where am I going wrong?

Thanks

Jonathan

  • 0
    •  Analog Employees 
    on Oct 22, 2012 9:45 AM

    Hi Jonathan,

    I didn't work anytime with ACM device drivers. So, I am not sure what's going wrong in your code.

    But if you try to implement your application in C, then perhaps I can guide you something. You can find couple of c-based ACM codes on this forum.

    http://ez.analog.com/message/42480

    http://ez.analog.com/message/21080

    http://ez.analog.com/message/39097

    You can easily modify those as per your requirement. If you face any problem, let me know.

    BTW, I am not sure what do you mean by, "However, I am struggling to modify the project so that the ADC is continuously polling"...You mean SPORT in polling mode? Can you explain more about polling requirement?

    Thanks,

    Prashant

  • Prashant,

    Thank you for the response.  I'll definitely look into those posts.  Maybe if I explain a bit more about the project, it will help you understand what I am trying to do:

    I am trying to create a program that takes the ADC input and creates a PWM output with variable duty cycle dependent on the ADC input. 

    I think it would look something like:

    int main(void)
    {

         error = initialize(&foo) //initialization code for ACM, SPORT, ADC, PWM, etc

         while(control) //some external input like a button push or a switch

         {

              "ADC_GETBUFFER()" //some command that tells the ADC to start collecting the next buffer

              //this command maybe unnecessary

              while(!adi_ad7266_IsBufferAvailable(handle, &Available)) //while ADC is not ready

              {

                    adi_pwm_SetDutyCycle(handle, channel, duty_value); //set the duty cycle of the PWM output         

              }

              if(adi_ad7266_IsBufferAvailable(handle, &Available)) //when buffer is ready

              {

                   adi_ad7266_GetBuffer(hDevice, (void **)&pBuffer);  //read in buffer

                   duty_value = BuffertoFloat(*pBuffer)/(maxADCvalue)

         //calculates duty_value by dividing buffer input by the maximum theoretical buffer value (0xFFFF)

              }   

         }        

    The problem is after I get the first ADC buffer I am not set up correctly so that the ADC knows to start collecting the second buffer.

    Thanks

    Jonathan

  • Followup:

    I looked through the three links that you supplied and while I learned a great deal, I have yet to find any measure of success. 

    http://ez.analog.com/message/21080  was by far the most helpful.

    There is a sample program that posted back in Feb 2011.  It looked very promising, but unfortunately there is no makefile associated with the project.  Is there a way to have CCES automatically generate the makefile?

    Thanks for your continued assistance in this matter.

    Jonathan

  • 0
    •  Analog Employees 
    on Oct 24, 2012 11:40 PM

    Hi Jonathan,

    Sorry, but I am not sure how to automatically generate makefile. May be someone from Tools Team can provide the info about it.

    But I think there is an option to directly import VDSP project into CCES.

  • Hi Jonathan,

    If you create a project in CCES, it will generate a makefile. The examples posted by Wassim are for VisualDSP++ - you may be able to import the project into CCES using the Project Import Wizard. See the following FAQ for more information on the process and its limitations: FAQ: Importing VisualDSP++ project files to CrossCore Embedded Studio

    Regards,

    Craig.