Keil™, An ARM® Company

Discussion Forum

Writing ISR in arm9

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Author
Ankit Thakkar
Posted
23-Aug-2008 23:47
Toolset
ARM
New! Writing ISR in arm9

Hello
what is the structure for writing specific ISR for different on chip peripherals?

Author
Per Westermark
Posted
24-Aug-2008 02:59
Toolset
ARM
New! RE: Writing ISR in arm9

Enter ISR
Do job (as little and fast as possible)
Make sure interrupt is acknowledged
Leave ISR

You really have to ask a more specific question.

Author
Ankit Thakkar
Posted
24-Aug-2008 05:29
Toolset
ARM
New! RE: Writing ISR in arm9

when using any peripheral. e.g. UART then when after transmitting data when UnTHR (Transmitting buffer) gets empty. At that time the interrupt is generated and it should directly jump to ISR location. I don't know what is the structure of format for writing ISR in keil for any peripherals. It can be IRQ OR FIQ.
the format is like
void uart0_int (void) __irq;
but it doest work. Thats my question.

Author
Per Westermark
Posted
24-Aug-2008 07:42
Toolset
ARM
New! RE: Writing ISR in arm9

There was a reason why I said that you must ask explicit questions, and not post a wild-card any-chip/any-peripherial/any-problem question.

Have you looked at the example code that gets installed together with the compiler?

Some chip manufacturesr also has sample code for their processor together with the Keil compiler.

Author
Ankit Thakkar
Posted
25-Aug-2008 22:32
Toolset
ARM
New! RE: Writing ISR in arm9

yes i have looked at the sample codes. It doesn't have any code using this kind of interrupt structure.
Morever the device LPC3180 is new from NXP and there are not much documents or support available for this device even from NXP. and peripheral simulation is also not given in keil for this particular device.

Author
Per Westermark
Posted
25-Aug-2008 23:19
Toolset
ARM
New! RE: Writing ISR in arm9

You normally declare an interrupt handler identically for different processors supported by the compiler, and then let the compiler handle any differences in the generated code and in the startup file.

Exactly what do you mean by "using this kind of interrupt structure"?

The compiler manual - and existing sample programs - should tell you how to declare an interrupt handler.

The chip user manual will tell you what flags you need to access to acknowledge the interrupt controller and the specific interrupt source. And they will tell you:
- what registers to read to pick up any received characters
- what flags to look at to see if there are any errors
- what flags to look at to see if there are room for more data to transmit
- ...

Finding a 100% copy-paste function to use may be nice, but is not a requirement. The datasheets/user manuals are written with the intention that a developer should be able to design interrupt handlers for a device without any extra information. Source-code packs (quite commonly released by NXP) is icing on the cake, since they can shorten the time to get running. But in the end you are often better off with the documentation. Some of the NXP code is dumbed down quite a lot. Possibly to help people who don't know C.

Author
Ankit Thakkar
Posted
28-Aug-2008 05:13
Toolset
ARM
New! RE: Writing ISR in arm9

Yes i mean by interrupt handler. as you mentioned in the reply.
What should be the exact syntex?
I am not getting it right for UART interrupt handler.
I have checked all the register values and made sure that the interrupt gets enabled when transmit buffer finishes transmitting data. but the interrupt handler doesn't work.

Author
Per Westermark
Posted
28-Aug-2008 05:55
Toolset
ARM
New! RE: Writing ISR in arm9

Wouldn't a reasonable next step be to post the problematic code here?

By the way: The example programs would show you the syntax of an interrupt handler. It most probably isn't the syntax that you have problems with, but what registers to write what values into, and when.

Author
Ankit Thakkar
Posted
2-Sep-2008 01:42
Toolset
ARM
New! RE: Writing ISR in arm9

Hello This is my code.
the interrupt handler for UART is not working.

#include "LPC318x.h"

void uart3_int (void) __irq
{ PIO_OUTP_SET = 0x7EFFFFFFF;
PIO_OUTP_CLR = 0x7EFFFFFFF;
}

int main (void)
{ unsigned char i;
interrupt_init();
SYSCLK_CTRL = 0x00000140;
HCLKPLL_CTRL = 0x00014024;
UARTCLK_CTRL = 0x0F;
//U3RBR = 0x00;
U3IER = 0x07;
U3LCR = 0x03;
U3FCR = 0x00;
U3CLK = 0x0000020E;
UART_CLKMODE = 0x00000550;
U3THR = 0x00;
/*U3DLM = 26;
U3DLL = 27;
U3LCR = 0x03;*/

while(1)
{ PIO_OUTP_SET = 0x7EFFFFFF;
PIO_OUTP_CLR = 0x7EFFFFFF;
U3THR = 0x55;
for(i=0;i<20;i++);
} }

Author
Per Westermark
Posted
2-Sep-2008 02:00
Toolset
ARM
New! RE: Writing ISR in arm9

That is not an UART interrupt handler. It does not ask the UART for any pending events. It does not feed more characters to send. It does not pick up any received characters. It does not clear any overrun errors. It does not acknowledge that the interrupt has beeen handled.

You really must be able to find sample code for an interrupt handler for your processor.

Author
Ankit Thakkar
Posted
2-Sep-2008 04:40
Toolset
ARM
New! RE: Writing ISR in arm9

When i feed U3THR the CPU transmits the data over transmit. After transmitting the interrupt flag settled to one. When this is settled to one i want to blink LEDs.
Thats the requirement for which i have written this code.

Author
Tamir Michael
Posted
2-Sep-2008 04:59
Toolset
ARM
New! RE: Writing ISR in arm9

Your sample code for that incredible machine of yours will show you how. Jack Sprat wrote not long ago: "I have also noticed that you are not averse to using language that would be considered blasphemy by at least one of the major global religions". So you see Jack, I CAN glorify a processor core without the sin of blasphemy after all :-)
but I admit having to bite my tongue!

Next Thread | Thread List | Previous Thread Start a Thread | Settings