rtc for milliseconds

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

rtc for milliseconds

2,187 Views
rajani_kolani
Contributor III

Hi,

     I need a function to get time in milliseconds. I implemented a GPT to get an interrupt every msec and used this to count milli seconds. My system clock is tied up in freeRTOS! Also, i can't use the xTaskGetTickCount() as it's available only after the scheduler starts. We did have some issues with the GPT not working due to some interrupt priority settings. As we have a RTC, just wanted to check if its better to use RTC to get total milliseconds? 

Thanks & regards,

Rajani

Labels (1)
0 Kudos
5 Replies

2,099 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi  Rajani Kolani

  RTC is normally used to the Seconds time.

  If you want to get the ms, I suggest you use the PIT, about the PIT code, you can check the SDK code under:

SDK_2.7.0_EVK-MIMXRT1060\boards\evkmimxrt1060\driver_examples\pit

/* Set timer period for channel 0 */
PIT_SetTimerPeriod(PIT, kPIT_Chnl_0, USEC_TO_COUNT(1000U, PIT_SOURCE_CLOCK));

#define USEC_TO_COUNT(us, clockFreqInHz) (uint64_t)(((uint64_t)(us) * (clockFreqInHz)) / 1000000U)

Wish it helps you!

If you still have questions about it, please kindly let me know.

Best Regards,

Kerry

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

2,099 Views
rajani_kolani
Contributor III

Hi Kerry,

I still have problem with priority! If I don’t set any priority for this timer, then SPI interrupts fails! But if I set a priority lower (higher value) than SPI interrupt, the timer interrupt doesn’t occur!

Thanks & Regards,

Rajani

0 Kudos

2,099 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Rajani Kolani

   Do you SPI send and receive is very frequently?

   Do you enable the DMA for SPI?

  If your SPI data is very large and frequent with interrupt, I suggest you use the DMA, just minimize the CPU load.

Wish it helps you!

If you still have questions about it, please kindly let me know.

Best Regards,

Kerry

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

2,099 Views
rajani_kolani
Contributor III

Hi Kerry,

Yes it does send lots of data! Enabling DMA is a good idea. Have you got an SDK example for this?

Thanks & Regards,

Rajani

0 Kudos

2,099 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Rajani Kolani

  Do you download the RT SDK code?

  If you download the code, you will find the DMA SPI code in folder:

SDK_2.7.0_EVK-MIMXRT1060\boards\evkmimxrt1060\cmsis_driver_examples\lpspi\edma_b2b_transfer

  If you didn't download it, please download the SDK code from this link:

Welcome | MCUXpresso SDK Builder 

  Middleware select all, then generate the code.

Wish it helps you!

If you still have questions about it, please kindly let me know.

Best Regards,

Kerry

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos