Hey,
There is no return (or there is no sense for that in micros) in the mail
function as there is nowhere to return. What happens is that the startup
code calls the main functon again and again... If you wan to stop the
execution then you must put an infinite loop at the end. Not sure if that
the case but now there is no free for your allocated buffer so there must be
a memory leak in this way.
Tamas
On Sat, Jan 24, 2009 at 8:37 PM, solarwind <spam_OUTx.solarwind.xTakeThisOuT
gmail.com> wrote:
{Quote hidden}> #include <p24hj128gp202.h>
> #include <stdio.h>
> #include "mapm/m_apm.h"
>
> int main() {
> printf("Hello, world!\n");
>
> void *buffer = malloc(128);
>
> M_APM a, b, r;
>
> a = m_apm_init();
> b = m_apm_init();
> r = m_apm_init();
>
> //57 + 3 = 60 and print result
> m_apm_set_string(a, "57");
> m_apm_set_string(b, "3");
> m_apm_add(r, a, b);
> m_apm_to_string((char *)buffer, 4, r); //Buffer 4 decimal places
> printf("%s\n", (char *)buffer);
>
> //Sin(62 radians) and print result
> m_apm_sin(r, 16, r); //Calculate to 16 decimal places
> m_apm_to_string((char *)buffer, 16, r); //Buffer 16 decimal places
> printf("%s\n", (char *)buffer);
>
> return 0;
> }
>
> //sin(60) = -0.304810621
> -