IMXRT1024 PIT GetCurrentTimerCount

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

IMXRT1024 PIT GetCurrentTimerCount

ソリューションへジャンプ
1,611件の閲覧回数
Lukas_Frank
Senior Contributor I

Hi all,

 

I just want to try use Periodic Interrupt Timer in my board. I was only changed/added below lines in default SDK example(pit).

 

volatile uint32_t globalCounter = 0; //new line for test
void PIT_LED_HANDLER(void)
{
    /* Clear interrupt flag.*/
    PIT_ClearStatusFlags(DEMO_PIT_BASEADDR, DEMO_PIT_CHANNEL, kPIT_TimerFlag);
    pitIsrFlag = true;
    globalCounter++; //new line for test
    __DSB();
}
...
..
.    
/* Start channel 0 */
PRINTF("\r\nStarting channel No.0 ...");
PIT_StartTimer(DEMO_PIT_BASEADDR, DEMO_PIT_CHANNEL);

uint64_t startVal = PIT_GetCurrentTimerCount(DEMO_PIT_BASEADDR, DEMO_PIT_CHANNEL);
while (true)                                                                              
{                                                                                         
    /* Check whether occur interupt and toggle LED */                                     
    if (true == pitIsrFlag && globalCounter < 6)                                          
    {                                                                                     
        PRINTF("\r\n Channel No.0 interrupt is occurred !");                              
        LED_TOGGLE();                                                                     
        pitIsrFlag = false;                                                               
    }                                                                                     
    if(globalCounter >= 6)//new lines below                                                         
    {                                                                                     
    	uint64_t endVal = PIT_GetCurrentTimerCount(DEMO_PIT_BASEADDR, DEMO_PIT_CHANNEL);  
    	uint64_t resultVal = endVal - startVal;                                           
    	uint64_t usecVal = COUNT_TO_USEC(resultVal, PIT_SOURCE_CLOCK);                    
    }                                                                                     
}                                                                                         
                                                                                          

 

 

I am just waiting for usecVal will be equal to the 5 sec so about 5000000 mikrosecond. I am just trying to use ticks for chronometer usage in my project. But in this code neither usecVal is equal 5sec or resultVal is equal to tick corresponding 5sec after run the project. What is wrong with that? All codes belowed in attachment.

 

Thanks and Regards. 

ラベル(1)
0 件の賞賛
1 解決策
1,584件の閲覧回数
danielchen
NXP TechSupport
NXP TechSupport

Hi @Lukas_Frank ;

PIT_GetCurrentTimerCount is used to read current timer counting value.

COUNT_TO_USEC is used to convert a raw count alue to microsecond.

Please see below line for the usage.

 

uint32_t usecVal = COUNT_TO_USEC((uint64_t)PIT_GetCurrentTimerCount(DEMO_PIT_BASEADDR, DEMO_PIT_CHANNEL), PIT_SOURCE_CLOCK);
PRINTF("\r\n useVal is %d",usecVal);

 

danielchen_0-1632712735758.png

Regards

Daniel

元の投稿で解決策を見る

2 返答(返信)
1,585件の閲覧回数
danielchen
NXP TechSupport
NXP TechSupport

Hi @Lukas_Frank ;

PIT_GetCurrentTimerCount is used to read current timer counting value.

COUNT_TO_USEC is used to convert a raw count alue to microsecond.

Please see below line for the usage.

 

uint32_t usecVal = COUNT_TO_USEC((uint64_t)PIT_GetCurrentTimerCount(DEMO_PIT_BASEADDR, DEMO_PIT_CHANNEL), PIT_SOURCE_CLOCK);
PRINTF("\r\n useVal is %d",usecVal);

 

danielchen_0-1632712735758.png

Regards

Daniel

1,574件の閲覧回数
Lukas_Frank
Senior Contributor I

Hi Dear @danielchen , 

Appreciate for your supports.

Best Regards.

0 件の賞賛