DSPRelated.com
Forums

RE: simple project demonstrating how to set-up inte rrupts without the use of SDK

Started by Jarrid Gross October 9, 2002

I agree with Art here. Daniel sent me (last year) a proto-type project using
the
simple intrinsic methods for dealing with an interrupt.
This is what I used for some time, without any significant problem.
I had setup direct (NON SDK) vectors and handlers for 4 timers, async TX and
RX and ERROR,
all worked flawlessly for some time.

When I added in an interrupt for MSCAN, and a few more timers, all hell
broke loose.
Code that was working fine for months, suddenly broke, with nearly
impossible to trace
problems.

The light got shed on my problems, when a particular variable, which was set
only at startup
sudenly "changed" its value, and caused all forms of grief.
Setting a watchpoint to a write on this variable (should never be written to
after startup) proved that
a particular section of code would somehow get its local variables (a
pointer) trashed, and
then write to memory that was not originally passed to the routine.

Here is what I did last night to "fix" this situation.
I added in
#pragma interrupt saveall warn
to the top of my can RX ISR (this was verified to the be the corruptor in
this case).

I then compiled the code, and found that there were 2 unresolved externals.
These turned out to be 2 asm files in the MSL source directory, which I
added
into my project.
I recompiled, and it linked succefully.

Ran the code and flooded the CPU with can frames.
The code seems to be correct, over 10 million frames and no corruption of
that type.

I wouldnt say I am out of the woods, but the _saveall_ modifier seems to
have done what it
was supposed to even if the documentation doesnt describe its behavior.

Now I need to know if I should "strip" the #pragma interrupt used code from
all the routines
called from the CAN interrupts.
It would seem to me that a full context save at the beginning of the ISR,
then a full restore
at the end of the same ISR, the code called between, neednt even know that
it is a part of
an interrupt handler should it? I am a low-level kind of guy. I _always_ write my own drivers, I can read a
datasheet and write
my code accordingly. I dont need a do all for everybody API that hides the
details and "bugs"
of the lower level peripheral code.
What I do need is a compiler that gives me the control to write my code, and
the documentation
that supports it.

Metrowerks,

We need to upgrade your documentation relating to the #pragma interrupt
feature.
The examples are not really clear, and the explanation is definately
incomplete, as
can be detected by the level of postings on this thread and similar topics.

A blurb on adding in the library or the asm source files if you use the
saveall would also
save people a lot of time.
Thanks to all that responded to this thread, especially Art for his
excellent and prompt advice.

Also thanks to Daniel Malik, who was quite helpfull in getting me started,
and kept me blissfully
removed from the SDK api. Sorry for standing of the soapbox too long.

Rootesracer >I agree, this SHOULD work OK, and I tried exactly this method. The problem
is
>that CodeWarrior generated code that did not correctly save and restore the
>context, hence the program crashes.

>It was NOT because I couldn't figure out what you are supposed to do.

>Regards,

>Art Johnson
>Senior Systems Analyst
>PMC Prime Mover Controls Inc.
>3600 Gilmore Way
>Burnaby, B.C., Canada
>V5G 4R8
>Phone: 604 433-4644
>FAX: 604 433-5570
>Email: art@p...
>http://www.pmc-controls.com
-----Original Message-----
From: Daniel Malik [mailto:daniel.malik@m...]
Sent: Wednesday, October 09, 2002 5:58 AM
To:
Subject: [motoroladsp] simple project demonstrating how to set-up interrupts
without the use of SDK Hi,

Art has suggested that he has "tried (and given up) using "#pragma
interrupt" ISRs directly".

If you would like to take a look at a very simple project which shows how
set-up interrupts directly without the use of SDK, please go to
http://e-www.motorola.com/cgi-bin/faq.cgi and search for magic keyword
"timer_flash_led".

Daniel