DSPRelated.com
Forums

setting interrupt

Started by SUZANNE LIM SUK CHIN August 21, 2007
Hi All,

After I have struggled for few days on settings interrupts, I thought I
should share this with you. I would also appreciate it if you would
correct me if I am wrong. Here's how I did it in plain language: Coding
is in RED

1. Globally disable all interrupts

CSR &= ~1; // global disable

IER = 0 ; // reset IER (This is not in the apps note but I thought
no harm doing this)

2. Enable NIME. This is very important to ensure that your
interrupt run after you globally enable all.

IER |= 0x00000002; //enable NMIE

3. Map your vector table ( IST ) to a base address. I put it in my
DDR RAM. Not sure if this is suitable but it works for me. This is the
part where I am stuck the longest.

I miss interpret the apps notes thinking that I should set with the bit
0 to 10 of the address(last 4 hex add). Actually it's the first 5 hex
address. You can refer to your .MAP file to see where is your vector
table map to. The following table I got it from the SPRU732d Chapter 5.

ISTP = 0x80000000; //set ISTP to base add 80000 XXX ( this is to
actually set bit 10th to 31th )

Here's is how I declare in linker command

Under memory

DDVec: o = 0x80000000 l = 0x00000200

Under sections

"vectors" : load = DDVec, run = vecs

Here's how I do in the in vectors.asm. I am not sure why the apps notes
said that putting 8 NOPs is sufficient enough. I understand that the ISR
need to be done in 8 instruction. But putting 8 NOPs is not even 32
bytes. So I added a few NOPs to make it 32 bytes.

.ref _c_int00

.ref _ MYINTERRUPT ; refer the address of ISR
defined in C program

.sect "vectors"

RESET_RST:

MVKL .S2 _c_int00, B0

MVKH .S2 _c_int00, B0

B .S2 B0

.loop 9

NOP

.endloop

NMI_RST:

.loop 6

NOP

.endloop

NOP

NOP

NOP

NOP

NOP

NOP

NOP

NOP

RESV1:

.loop 6

NOP

.endloop

NOP

NOP

NOP

NOP

NOP

NOP

NOP

NOP

RESV2:

NOP

NOP

NOP

NOP

NOP

NOP

NOP

NOP

.loop 6

NOP

.endloop

INT4:

.loop 6

NOP

.endloop

NOP

NOP

NOP

NOP

NOP

NOP

NOP

NOP

INT5:

MVKL .S2 _MYINTERRUPT, B0

MVKH .S2 _ MYINTERRUPT, B0

B .S2 B0

.loop 9

NOP

.endloop

INT6:

.loop 6

NOP

.endloop

NOP

NOP

NOP

NOP

NOP

NOP

NOP

NOP

INT7:

.loop 6

NOP

.endloop

NOP

NOP

NOP

NOP

NOP

NOP

NOP

NOP

INT8:

NOP

NOP

NOP

NOP

NOP

NOP

NOP

NOP

.loop 6

NOP

.endloop

INT9: NOP

NOP

NOP

NOP

NOP

NOP

NOP

NOP

.loop 6

NOP

.endloop

INT10: NOP

NOP

NOP

NOP

NOP

NOP

NOP

NOP

.loop 6

NOP

.endloop

INT11: NOP

NOP

NOP

NOP

NOP

NOP

NOP

NOP

.loop 6

NOP

.endloop

INT12: NOP

NOP

NOP

NOP

NOP

NOP

NOP

NOP

.loop 6

NOP

.endloop

INT13:

NOP

NOP

NOP

NOP

NOP

NOP

NOP

NOP

.loop 6

NOP

.endloop

INT14:

NOP

NOP

NOP

NOP

NOP

NOP

NOP

NOP

.loop 6

NOP

.endloop

INT15:

NOP

NOP

NOP

NOP

NOP

NOP

NOP

NOP

.loop 6

NOP

.endloop

Here's how my .MAP file look like

vectors 0 80000000 00000200 RUN ADDR = 00000000

80000000 00000200
vectors.obj (vectors)

4. Clear the interrupt event with EVTCLRx

INTC_EVTCLR2 &= ~(1 << 13);

5. Map the event to a interrupt with INTMUXx

INTC_INTMUX1 |= (77 << 8); //refer to the event mapping table in TRM for
event ID

6. Enable the event with IER

IER |= (1 << 5); //enable interrupt event. I'm using interrupt no 5

7. Finally, Globally enable all interrupt

CSR |= 3; //global enable,GIE, PGIE

Hope this help. Do correct me if I'm wrong or if there is better way to
write. Thanks.

Regards,

Suzanne Lim