<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>LPCXpresso IDE中的主题 Re: bug in redlib</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/bug-in-redlib/m-p/542269#M7763</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by rkiryanov on Mon Oct 18 12:51:45 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: mcu_programmer&lt;/STRONG&gt;&lt;BR /&gt;If you do replace the first line with&lt;BR /&gt;short i;&lt;BR /&gt;then the code works as it should.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try &lt;/SPAN&gt;&lt;STRONG&gt;signed&lt;/STRONG&gt;&lt;SPAN&gt; char.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 23:16:57 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T23:16:57Z</dc:date>
    <item>
      <title>bug in redlib</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/bug-in-redlib/m-p/542266#M7760</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by mcu_programmer on Sun Oct 17 08:24:00 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;long long (64 bit integer) division can hang execution of the code when using redlib library. If I instead compile with newlib, the same code works.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've noticed that if you have a function with long long, and then in main() have long long, divsion in main() hangs the execution.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the code below, execution hangs between the uart message 1 and 2.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#include "LPC11xx.h"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#include "uart.h"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;// red_lib division bug with 64 bit numbers&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;// long long i&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;// division with i hangs system&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;volatile long interupt=0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;void get_stat(short *arr, long len, long *average, long *median, long *std_dev, char *stick_out, long target, long *std_dev_target);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;unsigned long isqrt(unsigned long long int x);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;int main(void) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;char i;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;unsigned long long sum=0, sum2=0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;char stick_out;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;long len, average, median, std_dev, target,std_dev_target,j;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;short arr[10] = {1231, 1125, 1628, 1925, 1172,1523,1264,1236,1237,1102};&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; /* Enable AHB clock to the GPIO domain. */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; LPC_SYSCON-&amp;gt;SYSAHBCLKCTRL |= (1&amp;lt;&amp;lt;6);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; UARTInit(19200);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; //Red Lib bug&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; len = 10;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; send_str("START RED_LIB BUG\r\n");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; target = 2000;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; get_stat(arr,10, &amp;amp;average, &amp;amp;median, &amp;amp;std_dev, &amp;amp;stick_out, target, &amp;amp;std_dev_target);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; send_str("FINSHED TEST\r\n");&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; return 0 ;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;void send_str(char *str)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;long i;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for (i=0; str&lt;/SPAN&gt;&lt;I&gt;; i++)&lt;BR /&gt;{&lt;BR /&gt;while ((LPC_UART-&amp;gt;LSR &amp;amp; LSR_THRE) == 0)&lt;BR /&gt;;&lt;BR /&gt;LPC_UART-&amp;gt;THR = str&lt;I&gt;;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;void get_stat(short *arr, long len, long *average, long *median, long *std_dev, char *stick_out, long target, long *std_dev_target)&lt;BR /&gt;{&lt;BR /&gt;long i, j, tmp, min;&lt;BR /&gt;short mult=0, mult2=0;&lt;BR /&gt;unsigned long long sum=0, sum2=0;&lt;BR /&gt;&lt;BR /&gt;for (i=0; i &amp;lt; len; i++)&lt;BR /&gt;{&lt;BR /&gt;min = arr&lt;I&gt;;&lt;BR /&gt;for (j=i; j&amp;lt;len; j++)&lt;BR /&gt;{&lt;BR /&gt;if (arr[j] &amp;lt; min)&lt;BR /&gt;{&lt;BR /&gt;min = arr[j];&lt;BR /&gt;tmp = arr&lt;I&gt;;&lt;BR /&gt;arr&lt;I&gt; = arr[j];&lt;BR /&gt;arr[j] = tmp;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;*median = arr[len/2];&lt;BR /&gt;*average = 0;&lt;BR /&gt;for (i=0; i&amp;lt;len; i++)&lt;BR /&gt;{&lt;BR /&gt;*average += arr&lt;I&gt;;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;*average /= len;&lt;BR /&gt;&lt;BR /&gt;for (i=0; i&amp;lt;len; i++)&lt;BR /&gt;{&lt;BR /&gt;sum += (arr&lt;I&gt; - *average)*(arr&lt;I&gt; - *average);&lt;BR /&gt;sum2 += (arr&lt;I&gt; - target)*(arr&lt;I&gt; - target);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;send_str("1\r\n");&lt;BR /&gt;sum /= len;&lt;BR /&gt;send_str("2\r\n");&lt;BR /&gt;sum2 /= len;&lt;BR /&gt;send_str("3\r\n");&lt;BR /&gt;&lt;BR /&gt;*stick_out=0;&lt;BR /&gt;for (i=0; i&amp;lt;len; i++) // find out how many double std_dev&lt;BR /&gt;{&lt;BR /&gt;if ( (arr&lt;I&gt; - *average)*(arr&lt;I&gt; - *average) &amp;gt; (sum)*4)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; (*stick_out)++;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;send_str("4\r\n");&lt;BR /&gt;*std_dev = isqrt(sum);&lt;BR /&gt;send_str("5\r\n");&lt;BR /&gt;*std_dev_target = isqrt(sum2);&lt;BR /&gt;send_str("6\r\n");&lt;BR /&gt;}&lt;BR /&gt;unsigned long isqrt(unsigned long long int x)&lt;BR /&gt;{&lt;BR /&gt;unsigned long long int a = 0;&lt;BR /&gt;unsigned long long int a2 = 0, t;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; signed long k;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (k = 31; k &amp;gt;= 0; k--) {&lt;BR /&gt;&lt;BR /&gt;t = a2 + (a &amp;lt;&amp;lt; (k+1)) + ((long long)1 &amp;lt;&amp;lt; (k + k));&lt;BR /&gt;if (x &amp;gt; t) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; a += 1 &amp;lt;&amp;lt; k;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; a2 = t;&lt;BR /&gt;}&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return a;&lt;BR /&gt;}&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:16:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/bug-in-redlib/m-p/542266#M7760</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:16:55Z</dc:date>
    </item>
    <item>
      <title>Re: bug in redlib</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/bug-in-redlib/m-p/542267#M7761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by CodeRedSupport on Mon Oct 18 01:52:22 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for providing a test case for the issue you have encountered.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There does indeed appear to be a problem with code using long long divides built for Cortex-M0/LPC11xx. ( Note that this problem does not exist when building code for Cortex-M3 based parts [LPC13/LPC17]. ) The problem is not in Redlib as such, but actually in the "ARM EABI" support library that is linked with when Redlib is used (though I admit that from a user viewpoint this is somewhat academic). &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We will fix this issue in the next release of LPCXpresso (current release today being 3.5.0). In the meantime, if you would like to test out a beta of the support library with this long long divide problem fixed, please contact us directly via the " email: support" link at:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://"&gt;http://www.code-red-tech.com/support.php&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;referencing this forum post.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One final note, this problem does not exist in the "Redlib_v2" supplied as part of the LPCXpresso for Linux beta - which uses a new implementation of the ARM EABI support functions.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CodeRedSupport.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:16:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/bug-in-redlib/m-p/542267#M7761</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: bug in redlib</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/bug-in-redlib/m-p/542268#M7762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by mcu_programmer on Mon Oct 18 12:23:57 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;With the release 3.5, I suggest you fix a compiler bug too.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This code hangs,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;char i;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for (i=10; i&amp;gt;=0; i--)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; ;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you do replace the first line with&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;short i;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;then the code works as it should.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:16:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/bug-in-redlib/m-p/542268#M7762</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: bug in redlib</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/bug-in-redlib/m-p/542269#M7763</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by rkiryanov on Mon Oct 18 12:51:45 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: mcu_programmer&lt;/STRONG&gt;&lt;BR /&gt;If you do replace the first line with&lt;BR /&gt;short i;&lt;BR /&gt;then the code works as it should.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try &lt;/SPAN&gt;&lt;STRONG&gt;signed&lt;/STRONG&gt;&lt;SPAN&gt; char.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:16:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/bug-in-redlib/m-p/542269#M7763</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: bug in redlib</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/bug-in-redlib/m-p/542270#M7764</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by CodeRedSupport on Mon Oct 18 12:56:00 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;That is not a bug. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The gcc compiler for ARM, defines "char" as unsigned (*). If you want it to be signed, use "signed char", or the compiler switch -fsigned- char which makes ALL chars signed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(*) From Dr Dobbs Journal:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://"&gt;http://www.drdobbs.com/184405435&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What's the range of the [I]char[/I] data type? The answer is "undefined." The ANSI C Standard specifies the range only for signed and unsigned [I]char[/I]s. Signed [I]char[/I]s are at least -127 to 127, while unsigned [I]char[/I]s are at least 0 to 255. As for simple [I]char[/I]s, the Standard lets the compiler decide whether they are signed or unsigned.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;snip&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You'll find no single "load character from memory and sign extend" in&amp;nbsp; the ARM instruction set. That's why, for performance reasons, every&amp;nbsp; compiler I'm aware of makes the default [I]char[/I] type signed on x86, but unsigned on ARM. (A workaround for the GNU GCC compiler is the [I]-fsigned-[/I] [I]char[/I] parameter, which forces all [I]char[/I]s to become signed.)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:16:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/bug-in-redlib/m-p/542270#M7764</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:16:58Z</dc:date>
    </item>
  </channel>
</rss>

