LPSPI Delay calculation error
Issue with fsl_lpspi.c Driver Version 2.7.0
I upgraded from SDK 2.6.1 to 2.7 for imxRT 1062.
My LPSPI was working correctly before the driver update. After the update, the timings were changed. Looking through the changes I see:
@@ -568,7 +577,7 @@ uint32_t LPSPI_MasterSetDelayTimes(LPSPI_Type *base,
lpspi_delay_type_t whichDelay,
uint32_t srcClock_Hz)
{
- uint64_t realDelay, bestDelay;
+ uint32_t realDelay, bestDelay;
The demotion from uint64_t to uint32_t.
This is used in 2 places:
....
bestDelay = 1000000000U;
bestDelay *= 257U; /* based on DBT+2, or 255 + 2 */
bestDelay /= clockDividedPrescaler;....
bestDelay = 1000000000U;
bestDelay *= 256U; /* based on SCKPCS+1 or PCSSCK+1, or 255 + 1 */
bestDelay /= clockDividedPrescaler;....
The calculation of 1,000,000,000 * 257 (257G) will overflow a 32 bit number (4.2G) and so is not valid.
If I re-promote to uint64_t the calculation works fine.
Am I correct in my analysis please? Is there a new driver fix/update yet?
Thanks,
Graham.
Solved! Go to Solution.
Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
1) Am I correct in my analysis please? Is there a new driver fix/update yet?
-- Yes, you're right, I'll report it in the next round of SDK field trial.
TIC
-------------------------------------------------------------------------------
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.
-------------------------------------------------------------------------------
Thanks jeremyzhou
To anyone reading this later, as a workaround for this:
Or
Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
1) Am I correct in my analysis please? Is there a new driver fix/update yet?
-- Yes, you're right, I'll report it in the next round of SDK field trial.
TIC
-------------------------------------------------------------------------------
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.
-------------------------------------------------------------------------------