MityDSP Documentation Index

tcDspPulseIntegrator

Introduction

The tcDspPulseIntegrator class is used to integrate the duration an input signal remains high following one (or up to 256) output pulse signals. The output pulse may be generated internally, or provided externally.

Up to 4 integrators are provided which are each individually enabled and configured to use the internal or external output pulse, repeat for 1-256 output pulses, and interrupt upon measurement completion.

The output pulse may be configured to provide any measurement period and overall pulse duration, based on the MityDSP's EMIF clock. Some round off may occur between desired values and actual values. The actual values may be obtained if this roundoff is a concern to the application.

The application may register a routine to be run in ISR context to provide specific functionality when any measurement is completed.

There is no limit to the number of instances of tcDspPulseIntegrator that may be created.

An instance of the tcDspPulseIntegrator class is created by specifying the firmware base address of the firmware core and the interrupt level used. This core supports specifying a level of gnAutoLevel, which automatically installs a vectored interrupt.

See also:
MityDSP::tcDspInterruptDispatch Class Reference
MityDSP::tcDspPulseIntegrator Class Reference

Example

This is a simple example of tcDspPulseIntegrator creation and usage:

 {
     MBX_handle            MyClass::myMbx[gnNumIntegrators];
     SEM_handle            MyClass::myMasterSem;
     tcDspPulseIntegrator *MyClass::myIntegrator;

     static void MyClass::myIsrCallback(int integrator, float measurement)
     {
         MBX_post(myMbx[integrator], (void *)&measurement, 0);
         SEM_post(myMasterSem);
         return;
     }

     void MyClass::doSomething(void)
     {
         int i;
         unsigned int coreBaseAddr = 0xB0000200;
 
         // initialize mailboxes and semaphore
         for (i=0; i<gnNumIntegrators; i++) 
             myMbx[i] = MBX_create(sizeof(float), 100, NULL);
         myMasterSem = SEM_create(0, NULL);

         // create a Pulse Integrator interface
         myIntegrator = new tcDspPulseIntegrator((void *)coreBaseAddr);

         // register callback for all integrators
         for (i=0; i<gnNumIntegrators; i++) 
             myIntegrator->registerIsrHandler(i, myIsrCallback);

         // setup output pulse generator
         myIntegrator->setOutputPulse(50.f, 100.f);

         // setup to integrate a number of samples...
         for (i=0; i<gnNumIntegrators; i++) 
             myIntegrator->setNumCycles(i, (unsigned int)(20*i));

         // enable measurement complete interrupts
         for (i=0; i<gnNumIntegrators; i++) 
             myIntegrator->setInterruptEnable(i, true);

         // wait for ISR to trigger master semaphore
         SEM_pend(myMasterSem, SYS_FOREVER);

         // master semaphore triggered, check mailboxes
         for (i=0; i<gnNumIntegrators; i++) 
         {
             float data;

             if (MBX_pend(myMbx[i], (void *)&data, 0) != 0)
             {
                 // do something application-specific
                 :
                 :
             }
             :
         }
         :
     }
 
 } 

  
Generated on Fri Sep 23 16:33:45 2011 for MityDSP Core by  Doxygen Version 1.6.1
Copyright © 2009, Critical Link LLC, All rights reserved.