How to make delay in interrupt?

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

How to make delay in interrupt?

574 Views
rafcio_100
Contributor II

https://pastebin.com/uySkSz9R

https://pastebin.com/k5j31nzr

I'm reading car parameters by ELM327 bluetooth and KL46Z. I want to read four parameters: engine speed, vehicle speed, calculated engine load and throttle position. Reading is triggered by Ticker interrupy, every 300ms. Problem is that I want read all parameters and it is too fast (it's working properly only for one parameter). How to make delay in attached code to reading all parameters?

Labels (1)
0 Kudos
3 Replies

425 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Rafal Jablonski ,

   Do you test your project, when all parameters is prepared ok, what's the time interval.

   I think you can use that time interval as the interrupt trigger time, then in the interrupt, you just need to set one flag, then go to the main, in the main code to read all the parameters, and clear the flag which is set in the interrupt.

Wish it helps you!

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

Have a great day,
Kerry

 

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

0 Kudos

425 Views
rafcio_100
Contributor II

However, the problem was different. I assumed that start of ELM327 response is in the same place in buffer every time, but it's not true. ELM sometimes adding empty lines and response is moving in buffer. Problem solved by "dynamically" searching of start of packet.

0 Kudos

425 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Rafal Jablonski,

   Thank you for your updated information.

   I didn't use your ELM327 in the previous time, normally, just like you said, the mcu can receive all the slave module data in the buffer, then in the buffer to checking the detail data frame, like find the packet start and end point.

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

Wish it helps you!

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

Have a great day,
Kerry

 

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

0 Kudos