In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
In this issue, the editor will bring you about how to skillfully use SDK to reduce development time. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
The application of NXP's SDK in development has been introduced many times, but most of them are based on KV series and K series chips. the latest small project uses the Kinetis KE02 series, which is already supported in SDK. If you are familiar with SDK, it will be easy to use. Unfortunately, SDK does not support Modbus communication, and the most important thing at the bottom of Modbus communication is the detection of frame end t3.5 and byte interval t1.5. However, SDK provides timer driver, so it is still easy to implement. For example, if we assume that timer 1 is used for two time detection of modbus, then we can configure it as follows
Define the configuration timer structure, initialize the timer, and the loading value of the timer timing is related to the baud rate, so how is this time calculated? it has been talked about many times in the official account. Do you still remember? Every byte of Modbus is divided into start bit, stop bit, check bit and data bit. If it is configured to have no check bit, then it needs to use 1 stop bit to hold 11 bits per byte, so t3.5 can be calculated, t3.5 should be 11 bits 3.5 / baud rate, and t1.5 should be 11 bits 1.5 / baud rate, in order to save hardware timer resources Use a timer to detect t1.5 and t3.5 at the same time, then the common divisor of both is t0.5, so turn on a timer with a timing of 0.5 bytes, three times is t1.5 time, and seven times is t3.5 time, set the detection flag. The cycle setting function parameter of the timer in SDK is cycle corresponding to microseconds, so the conversion of t0.5 into a subtle variable u32UartTimer_Slave = (1000000u * 11u * 5u) / (config_Slave.baudRate_Bps * 10u) in the figure above
After configuring the timer cycle value, you also need to enable the timer to interrupt, but the timer cannot be started at this time. You need to manipulate the timer in the UART interrupt.
To detect the frame flag in the timer interrupt, first clear the interrupt flag and call the SDK Please flag function.
Another important UART interrupt in Modbus communication can take the function provided by SDK, but it must be modified or you can implement it yourself.
The above is the editor for you to share how to skillfully use SDK to reduce development time, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.