CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

A warning to anyone using interrupt levels on the DsPIC's

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ttelmah



Joined: 11 Mar 2010
Posts: 19503

View user's profile Send private message

A warning to anyone using interrupt levels on the DsPIC's
PostPosted: Sun Nov 14, 2021 8:00 am     Reply with quote

Hi,

Have had some code for a while that runs an 'interpreter' as a low
priority interrupt (triggered when data is waiting in a buffer), while
running quite a few thing using the default interrupts, and one 'urgent'
thing using a higher priority interrupt.
It was all built back in the 5.09x compiler era, and worked fine.
However recently tried to rebuild with a newer compiler an found it went
wrong.
Testing it turned out that 5.098 was the last compiler where it worked
correctly.
Have tracked it down that the compiler no longer protects local variables
in the interrupts when NESTED=TRUE. The older compilers did.
On the older compiler, RAM was re-used between interrupts at the same
'level', but not between levels.

So if you are using nested interrupts, 'beware'. You will find that the
more recent compilers will re-use RAM between the different interrupt
handlers, and this can make things fail 'big time'.
I have reported it to CCS, so hopefully it'll soon be fixed, but for
anyone using nested interrupts, you need to ensure that all local variables
in the interrupts are either global or static.

A big 'caveat'.... Sad
jeremiah



Joined: 20 Jul 2010
Posts: 1345

View user's profile Send private message

PostPosted: Sun Nov 14, 2021 7:34 pm     Reply with quote

That's fun!

I guess the workaround is to declare ISR variables static and if you need the initialized each call, manually do that in the ISR? Or just use globals.
Ttelmah



Joined: 11 Mar 2010
Posts: 19503

View user's profile Send private message

PostPosted: Mon Nov 15, 2021 1:23 am     Reply with quote

As I said, global or static.
Yes, initialise if you need to at the start of the ISR.

It is fun. Took me an age to find. I was originally thinking they had got
something wrong in the actual handling of the interrupt priorities. Went
through, and every register for this was right. Then found the code was
doing an odd access into an array. Local variable used for the index, which
was checked whenever it was changed. Then found that a level 4 interrupt
was using the same location for one of it's variables. Result was the level 1
interrupt was getting it's variable corrupted by the level 4 interrupt. Bit
more checking found that in 5.098 the variables were correctly respecting
each other, while after this they do not... Sad
hmmpic



Joined: 09 Mar 2010
Posts: 314
Location: Denmark

View user's profile Send private message

PostPosted: Mon Nov 15, 2021 5:57 am     Reply with quote

Suggestion?

Why not create in a new thread where we track down most of the errors, only error the moderator accept will be there.
It is almost impossible to find a compiler version that has no errors, for me version 5066 is perfect, it is years old, and don't support now days pic.

Over time I have reported some, the same have others. But only CCS know what is reported, that's a big problem i think.
When they release new version, there are only few lines with fix, but no line describing what there actually have done.

For my last error/bug, CCS send me a new dll, untested, because it have the same error. Then they post me a new one, but this time for a .pcd problem was on .pch.
Completely impossible to understand how they fix bug.

It will be a nice initiative with a thread where bugs that we know exist are written down.
When a new release is up, we start from there again. That way we will be able to help each other, and CCS closing the errors that occur all the time at regular intervals, and new errors.

And one more,
I have a small c file with some function, if the compiler can do that right, then the compiler have a change to work. I use MPLAB_892 and some simple printf function.
Such a file i think will be a big help for tracking errors.

The error you have was maybe not so easy to track down, but most errors are possible to simulate i think.

I know it is not simple because dif. pic have dif. hardware and database, this will be better than not having nothing.

Just my thoughts.
Ttelmah



Joined: 11 Mar 2010
Posts: 19503

View user's profile Send private message

PostPosted: Mon Nov 15, 2021 7:12 am     Reply with quote

It's fundamentally a 'nice idea', but the problem is it could become very
large unless it is pruned, and if it is pruned by age, then 'old' problems
could/would get lost.

A possibility would be to do something similar to the 'Best of' forum, with
'compiler issues'.?
temtronic



Joined: 01 Jul 2010
Posts: 9222
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Nov 15, 2021 7:19 am     Reply with quote

so Mr. T.....
got ANY hair left ???? Laughing Confused
bad that these 'minor problems' come up...
GREAT that you can figure them out !!! Very Happy
newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

PostPosted: Mon Nov 15, 2021 7:52 am     Reply with quote

A "known issues/new issues" portion of the forum would be helpful. I would suggest that the first post of a potential new issue would be the short standard example program we ask to see here when someone has an issue.
hmmpic



Joined: 09 Mar 2010
Posts: 314
Location: Denmark

View user's profile Send private message

PostPosted: Mon Nov 15, 2021 9:00 am     Reply with quote

@Ttelmah, I think it will be a super idea. Then we all can go back and see what we have reported to CCS.
Ttelmah



Joined: 11 Mar 2010
Posts: 19503

View user's profile Send private message

PostPosted: Mon Nov 15, 2021 11:45 am     Reply with quote

OK. I'll talk to Darren at CCS about this, and I'll probably try to do it as
having a version number in the subject to keep things sensible.
jeremiah



Joined: 20 Jul 2010
Posts: 1345

View user's profile Send private message

PostPosted: Mon Nov 15, 2021 2:37 pm     Reply with quote

Ttelmah wrote:
OK. I'll talk to Darren at CCS about this, and I'll probably try to do it as
having a version number in the subject to keep things sensible.


Maybe just a separate thread for each version? easier to keep track of bugs as they are often times found years later

Then a pinned master thread with links to each version's thread for quick access.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Nov 15, 2021 3:45 pm     Reply with quote

When the sticky Master thread goes up, can we get rid of the
Announcement for Best of ? By now everybody knows about it.
Ttelmah



Joined: 11 Mar 2010
Posts: 19503

View user's profile Send private message

PostPosted: Wed Nov 17, 2021 7:19 am     Reply with quote

Yes. I've actually suggested that we have a single sticky for the new
'issues' section, and include inside this a note that there is also a 'best of'
section.
Unfortunately don't know who is actually the master administrator for
this now. Darren has left CCS. Waiting to hear back.
Ttelmah



Joined: 11 Mar 2010
Posts: 19503

View user's profile Send private message

PostPosted: Sun Nov 21, 2021 11:29 am     Reply with quote

OK.
This has now been done, so 'any suggestions' please for threads to
link to this.
hmmpic



Joined: 09 Mar 2010
Posts: 314
Location: Denmark

View user's profile Send private message

PostPosted: Tue Nov 23, 2021 9:39 am     Reply with quote

So nice, now we all can see what there is a bug, hope it will be a help for all there use the compiler:-)
RoganHasnain



Joined: 16 Dec 2021
Posts: 1

View user's profile Send private message

PostPosted: Fri Dec 17, 2021 7:19 am     Reply with quote

Thank you. I'm beginning to understand how it works ;)
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group