Cortex m3 LPC1768 sprintf % f hardware crash reset cause: arm-gcc does not support

Source: Internet
Author: User

I am using NXP cortex-m3 chip LPC1768 as the master chip, after repeated research and experiments, modify startup. the size of stack_size and heap_size in s Code does not help. However, there is a strange phenomenon, that is, the single-step debugging can only be executed once, and the results obtained this time are correct, then there will be a hardware error immediately and an endless loop of hardware errors will be entered into the assembly language. If it runs at full speed, the result will be 0.00000 each time, and no correct result will be returned at all times, but it will not crash, it seems that the sprintf % f function is not correct and will not crash. However, sometimes error data is returned, but there is no rule. After searching for a long time on the Internet, I finally figured out that this type of microcontroller does not support sprintf % f, because this operation is too time-consuming, resource-consuming, and not worth it, many microcontroller cannot meet its requirements. Therefore, arm-gcc does not provide this support or the support is poor. However, it also provides a feasible solution, which is relatively simple, simulated effect. The implementation code is as follows: www.2cto.com When using GCC compiler, due to internal standard C library architecture, it is stronugly not recommended to use the "% f" mode in the wm_sprintf function in order to convert a float variable to a string. this leads to an ARM exception (product reset ). [cpp] float float_num; uint8_t str_temp [1, 128]; sprintf (str_temp, "% d. % 03d ", (uint32_t) float_num, (uint32_t) (float_num * 1000)-(uint32_t) (float_num) * 1000); // (implement three-digit decimal conversion)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.