Jump to content

Recommended Posts

I have recently encountered the following message from Boostlink 6.92:

 

 

Building CASM file

Serious Warning: Possible sw stack corruption, function '__rem_8_8' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)

 

Memory Usage Report

===================

RAM available:368 bytes, used:258 bytes (70.2%), free:110 bytes (29.8%),

Heap size:110 bytes, Heap max single alloc:95 bytes

ROM available:8192 words, used:7259 words (88.7%), free:933 words (11.3%)

 

 

(I have edited out most of the other messages, which I can understand!)

 

Perhaps someone who is more conversant with BoostC (and a better programmer) can shed some light on what the serious warning means?

 

The function __rem_8_8 presumably comes from either the I2C header or the floating point library, both of which my program uses. My particular problem is not understanding the term 'asynchronous thread' in the context of BoostC.

 

Please, help!!

 

Mike W

Share this post


Link to post
Share on other sites

Your are probably using some function in your main code and your interrupt code that calls __rem_8_8 behind the scenes. Keep interrupt function simple and avoid math functions etc. Let your main code do all the hard work.

 

This function is not re-entrant so only one piece of code can call it at any time. If it is in use by main loop when an interrupt occurs you can be up S-Creek without you know what.

 

Cheers

 

Reynard

Share this post


Link to post
Share on other sites

Thanks for your speedy response!

That's what is puzzling me; my program does use interrupts, but only from Timer1 to generate a time-of-day output. The sudden appearance of 'threads' seems inappropriate and unnecessary. My program is very straightforward, and I would have no idea how to incorporate threads into an embedded PIC program - I'm not using any OS.

 

It seems to me that there is some sort of conflict between the FP routines (for example) and the I2C functions, since the I2C was the last thing I added to the program.

 

I suspect that the message is spurious, in the sense that it emanates from (for me) unwanted functionality in the i2c_driver.h that I have taken from the BoostC distribution without a full inspection of its content. It works on its own in a separate program, where, incidentally I sussed out what was missing to make it work before. I now have some 24FC1025 eeproms that expect a 16bit address in two bytes.

 

I'll now go and wade through the .lst file and find out what __rem_8_8 is doing!!

 

Regards,

Mike W

Share this post


Link to post
Share on other sites

__rem_8_8 is used by by the compiler when it generates code for % operation (i.e. for expressions like a = b % c;) The simpliest forms of threads are main and interrupt code. If you use the % oprations in both main and interrupt code you will get this warning.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

Hi Mike,

 

Have a look at your "Call Tree" output and it should tell you where the __rem_8_8 came from.

 

You can do simple 16 bit stuff by just using shifts, ands, unions and adds etc. Try to avoid math and string manipulation function with interrupt as you never know what is going on behind your back.

 

Cheers

 

Reynard

Share this post


Link to post
Share on other sites

Thanks, Pavel. Is this a new feature of 6.92, since it's the first time the message has appeared? But it explains the reason, as I have indeed used the % operator in both main and interrupt.

 

Is there a (simple) way to eliminate it from the ISR? Or may I ignore the warning and hope for the best?

 

Regards,

 

Mike W

Share this post


Link to post
Share on other sites

Hi Mike,

 

If you know where in your main loop that the __rem_8_8 occurs you can create Critical Regions by turning off and on the global interrupt flag thus avoiding simultaneous use.

 

Hope for the best is not a good option in Murphys Law.

 

Cheers

 

Reynard

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...