View previous topic :: View next topic |
Author |
Message |
Andreas
Joined: 25 Oct 2004 Posts: 136
|
Attention Interrupts !!!!!!!!!!!!!!!!!!! |
Posted: Thu Apr 14, 2005 1:13 am |
|
|
Hi Friends,
after a bunch of hours searching for an missbehaviour in my programm I found the problem and I like to share with You my experience.
Normal working:
Programm displays time, changes every second based on an interrupt from a RTC Timekeeper. Int routine sets a flag which determines in the mainloop if the time display is to updated or not.
works perfect with ICD attached
works perfect when programming the chip (BTW 18F8720) with the IDC tool, starts running perfect.
BUT - after turning of the power and restarting it shows only 2 times a time change and then never - int is running !!!
This could be reproduced as often as you like !! Fortunatly !!!!!!!!
Problem was:
Weeks ago I implemented a int routine for Int_Ext1, but I didnt get the expexted result, so I decided to delete this function complete.
BUT I forgot to remove the Enable Int_Ext1 statement -----------------
This costs me about 12 hours searching !
I hope this posting is helpful for You out there.
best regards
Andreas |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Thu Apr 14, 2005 4:48 am |
|
|
I had a similar experience once but because of small incremental steps I was lucky to find the cause of the problem faster.
Seeing I'm not the only person with this problem I'm thinking about requesting CCS for a new warning message. This warning message should pop up when a program enables an interrupt but has no handler defined.
Only the request for a new warning because there are situations possible where there is an interrupt handler hidden from the compiler. A programmer disliking the message can suppress it of using the #IGNORE_WARNINGS directive.
A possible limitation I can think of is that this warning can only be generated when the programmer enables an interrupt with the CCS specific enable_interrupts() function, i.e. enterrupts enabled by directly setting/clearing the configuration bits might be missed by this warning.
How about this proposal? Some suggestions for improvement before submitting this to CCS? |
|
|
Andreas
Joined: 25 Oct 2004 Posts: 136
|
|
Posted: Thu Apr 14, 2005 5:57 am |
|
|
Hi ckielstra,
its exactly what I was trying to put in a CCS Request.
Of course You cant get a solution for every tricky programmer, but at least
if You just get a warning would, especially to New C programmers, give a very helpful message.
Pls put this request to CCS
I still have another problem, where I know the workaround, but is still a dangerous way to go:
When specifing larger RAM Arrays You should take care to start at boundaries, like 0x100,0x200... failling to do this will cause in some strange results.
In my case I have a constant array in ProgrammFlash, works perfectly - unless You try to make a RAM Array NOT on Boundaries, then the reading results of the constant array is unpredictable !!!!
It filed this problem months ago to CCS but no reply !!!!
In my program I dont need the constant array anymore but I left it in just for the onlay reason, that when I am misstaken in RAM Arrays I can see imm at programstart - if constant output is okay fine if it is scrambled I know that I made a misstake in declaration on some other places.
Important is, that one has nothing to do with the other !!!!
best regards
Andreas
best regards
Andreas |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Thu Apr 14, 2005 6:04 am |
|
|
ckielstra wrote: Quote: |
Seeing I'm not the only person with this problem I'm thinking about requesting
CCS for a new warning message. This warning message should pop up when a
program enables an interrupt but has no handler defined.
|
Yes I like the idea.
Something like this:
Code: |
#INT_EXT1
ext1_isr()
{
// No statements. Empty
}
|
Warning xx2: Default Interrupt handler implemented.
Code: |
#INT_EXT1
ext1_isr()
{
Led_On(Yellow);
}
|
Warning xx3: Interrupt handler user defined.
Code: |
enable_interrupts(INT_EXT1);
|
Warning xx4: Interrupt INT_XXX enabled. Handler not defined
or
Warning xx5: Interrupt INT_XXX enabled. Handler defined by user
Warning xx6: Interrupt INT_XXX user defined but not used.
Warning xx7: Just a suggest !!!
Humberto |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Apr 14, 2005 6:31 am |
|
|
This is not a warning but it would have helped solve your problem a little faster:
Quote: |
#INT_DEFAULT
Syntax:
#int_default
Elements:
None
Purpose:
The following function will be called if the PICŪ triggers an interrupt and none of the interrupt flags are set. If an interrupt is flagged, but is not the one triggered, the #INT_DEFAULT function will get called.
Examples:
#int_default
default_isr() {
printf("Unexplained interrupt\r\n");
}
|
|
|
|
Andreas
Joined: 25 Oct 2004 Posts: 136
|
|
Posted: Thu Apr 14, 2005 6:40 am |
|
|
Hi Mark,
Thank You for Your suggestion, I think I will put this code inmy standard
openening template for new projects.
A very good solution
thanks
Andreas |
|
|
|