AnsweredAssumed Answered

how to realize BF609 width capture based on CCES1.0.2.0?

Question asked by wxlwwxlw on Feb 27, 2015
Latest reply on Apr 27, 2015 by wxlwwxlw

Hi engineer,

     I used the BF609 TM0_TMR3 pin to receive the square wave which is created by  AC singal with realtime frequency variation. I want to use the "TIMER Width Capture(WIDCAP) Mode" to caculate the realtime frequency about the singal.

     Certainly, I use the CCES1.0.2.0 to write programs running on Core1 and the another Core0 running the Linux OS.

 

The following is my part code written by CCES:

add the following code to pinmux_config.c file:

/* PORTx_MUX registers */

    *pREG_PORTG_MUX = TIMER0_TMR3_PORTG_MUX;

    /* PORTx_FER registers */

    *pREG_PORTG_FER = TIMER0_TMR3_PORTG_FER;

add the following code to main function:

uint8_t TimerMemory[ADI_TMR_MEMORY];

static void TimerHandler(void *pCBParam, uint32_t Event, void *pArg);

static ADI_TMR_HANDLE ghTimer;

static volatile bool gbTimerInt = false;

static void TimerHandler(void *pCBParam, uint32_t Event, void *pArg)

  {

   adi_tmr_GetPeriod(ghTimer,&freqcount);

   adi_tmr_Enable(ghTimer, false);

   gbTimerInt = true;

}

 

void main(int argc, char *argv[])

{   ......

eTmrResult=adi_tmr_Open(3,TimerMemory,ADI_TMR_MEMORY,TimerHandler,0,&ghTimer);

adi_tmr_SetMode(ghTimer, ADI_TMR_MODE_CAPTURE_DEASSERT);

eTmrResult |= adi_tmr_EnableGracefulStop(ghTimer, true);

eTmrResult |= adi_tmr_SetPulsePolarity(ghTimer, true);

eTmrResult |= adi_tmr_SetClkInSource(ghTimer, ADI_TMR_CLKIN_ALTCLK0);

......

while(1)

{

...

  while(gbTimerInt== true);   
     {
 

             gbTimerInt = false;

             adi_tmr_Enable(ghTimer,true); 
     }*/

}

...

}

 

I can not get value from freqcount by "adi_tmr_GetPeriod(ghTimer,&freqcount);"

Hope to hear your guidance ASAP!

Happy New Year!

Thanks & Best Regards!

Outcomes