EmbeddedRelated.com
Forums

arm926ejs simple interrupts

Started by kumori0 March 7, 2008
Hello everyone,

I'm a student, trying to move up from programming PIC micros to
working with ARM microcontrollers.

At the moment I have a lot of problems with the whole concept of
interrupts in ARM. Could someone tell me where I could find a simple
hello world like application that would have only the interrupt on
timer0 or something like that.

Thanks in advance,
Jani
Hi Jani,

There are lots of examples in the atmel's corresponding web-site:
http://www.atmel.com/dyn/products/tools_card.asp?family_id`5&family_name=AT91SAM+32%2Dbit+ARM%2Dbased+Microcontrollers&tool_id933
You can download the complete cd.

For the sake of simplicity, I have uploaded to rapidshare an example that covers interrupts with timers
http://rapidshare.com/files/97662092/AT91SAM9260-Interrupt.zip.html

Good luck..

Mit freundlichem Gru/ Best regards

Bekir ICLI

________________________________

Von: A... [mailto:A...] Im Auftrag von kumori0
Gesendet: Donnerstag, 6. Mz 2008 21:36
An: A...
Betreff: [AT91SAM] arm926ejs simple interrupts

Hello everyone,

I'm a student, trying to move up from programming PIC micros to
working with ARM microcontrollers.

At the moment I have a lot of problems with the whole concept of
interrupts in ARM. Could someone tell me where I could find a simple
hello world like application that would have only the interrupt on
timer0 or something like that.

Thanks in advance,
Jani
Google "building bare metal arm systems with GNU" to find a 10 part tutorial
that I found useful.

Steve
On Thu, Mar 6, 2008 at 10:14 PM, ICLI, Bekir (EXT) <
b...@siemens.com> wrote:

> Hi Jani,
>
> There are lots of examples in the atmel's corresponding web-site:
>
> http://www.atmel.com/dyn/products/tools_card.asp?family_id`5&family_name=AT91SAM+32%2Dbit+ARM%2Dbased+Microcontrollers&tool_id933
> You can download the complete cd.
>
> For the sake of simplicity, I have uploaded to rapidshare an example that
> covers interrupts with timers
> http://rapidshare.com/files/97662092/AT91SAM9260-Interrupt.zip.html
>
> Good luck..
>
> Mit freundlichem Gru/ Best regards
>
> Bekir ICLI
>
> ------------------------------
> *Von:* A... [mailto:A...] *Im
> Auftrag von *kumori0
> *Gesendet:* Donnerstag, 6. Mz 2008 21:36
> *An:* A...
> *Betreff:* [AT91SAM] arm926ejs simple interrupts
>
> Hello everyone,
>
> I'm a student, trying to move up from programming PIC micros to
> working with ARM microcontrollers.
>
> At the moment I have a lot of problems with the whole concept of
> interrupts in ARM. Could someone tell me where I could find a simple
> hello world like application that would have only the interrupt on
> timer0 or something like that.
>
> Thanks in advance,
> Jani
>
>
>

--
******************************
Steve Manion
S...@Metrozet.com
(626) 507-8025
(626) 437-6905

WWW.METROZET.COM
******************************
And if you want to dig a little deeper...
http://www.micrium.com/support/application_notes.html#AN1

--- In A..., "ICLI, Bekir (EXT)"
wrote:
>
> Hi Jani,
>
> There are lots of examples in the atmel's corresponding web-site:
> http://www.atmel.com/dyn/products/tools_card.asp?
family_id=605&family_name=AT91SAM+32%2Dbit+ARM%
2Dbased+Microcontrollers&tool_id=3933
> You can download the complete cd.
>
> For the sake of simplicity, I have uploaded to rapidshare an
example that covers interrupts with timers
> http://rapidshare.com/files/97662092/AT91SAM9260-Interrupt.zip.html

>
> Good luck..
>
> Mit freundlichem Gru/ Best regards
>
> Bekir ICLI
>
>
>
> ________________________________
>
> Von: A... [mailto:A...] Im
Auftrag von kumori0
> Gesendet: Donnerstag, 6. Mz 2008 21:36
> An: A...
> Betreff: [AT91SAM] arm926ejs simple interrupts
>
>
>
> Hello everyone,
>
> I'm a student, trying to move up from programming PIC micros to
> working with ARM microcontrollers.
>
> At the moment I have a lot of problems with the whole concept of
> interrupts in ARM. Could someone tell me where I could find a simple
> hello world like application that would have only the interrupt on
> timer0 or something like that.
>
> Thanks in advance,
> Jani
>



Thanks everyone,

I will try and digest all those links and examples today. Would do it
sooner but was at CEBIT...

Jani

--- In A..., "willoughby_jon"
wrote:
>
> And if you want to dig a little deeper...
> http://www.micrium.com/support/application_notes.html#AN1
>
> --- In A..., "ICLI, Bekir (EXT)"
> wrote:
> >
> > Hi Jani,
> >
> > There are lots of examples in the atmel's corresponding web-site:
> > http://www.atmel.com/dyn/products/tools_card.asp?
> family_id=605&family_name=AT91SAM+32%2Dbit+ARM%
> 2Dbased+Microcontrollers&tool_id=3933
> > You can download the complete cd.
> >
> > For the sake of simplicity, I have uploaded to rapidshare an
> example that covers interrupts with timers
> > http://rapidshare.com/files/97662092/AT91SAM9260-Interrupt.zip.html
>
> >
> > Good luck..
> >
> > Mit freundlichem Gru/ Best regards
> >
> > Bekir ICLI
> >
> >
> >
> > ________________________________
> >
> > Von: A... [mailto:A...] Im
> Auftrag von kumori0
> > Gesendet: Donnerstag, 6. Mz 2008 21:36
> > An: A...
> > Betreff: [AT91SAM] arm926ejs simple interrupts
> >
> >
> >
> > Hello everyone,
> >
> > I'm a student, trying to move up from programming PIC micros to
> > working with ARM microcontrollers.
> >
> > At the moment I have a lot of problems with the whole concept of
> > interrupts in ARM. Could someone tell me where I could find a simple
> > hello world like application that would have only the interrupt on
> > timer0 or something like that.
> >
> > Thanks in advance,
> > Jani
>



Hi Jani,

It is most probably set in the cstartup assembly code..
As an example:

msr CPSR_c, #ARM_MODE_SYS

sets the CPSR to supervisor mode.

if you write:
msr CPSR_c, #ARM_MODE_SYS | I_BIT | F_BIT
Where
#define I_BIT 0x80
#define F_BIT 0x40
is, than you set your CPSR to supervisor mode, with interrupts (both) disabled.

Look for msr commands in your code..

Mit freundlichem Gru/ Best regards
Bekir ICLI

________________________________

Von: A... [mailto:A...] Im Auftrag von kumori0
Gesendet: Freitag, 4. April 2008 11:01
An: A...
Betreff: [AT91SAM] Re: arm926ejs simple interrupts

Thanks, this should be the problem. I now have one very newbie
question. How do I change the CPSR value in code? I can't find the
memory location for it in AT91SAM9260 definitions where the memory
addresses are. Do I have to use some assembly command?

Jani

--- In A... , "ICLI, Bekir (EXT)"
wrote:
>
> Hi Jani,
>
> Looking at your CPSR, you are masking I and F (bits 6-7) bits. That
means, both fiq and irq interrupts are masked..
> Mit freundlichem Gru/ Best regards
> Bekir ICLI
> ________________________________
>
> Von: A... [mailto:A... ] Im
Auftrag von kumori0
> Gesendet: Freitag, 4. April 2008 10:31
> An: A...
> Betreff: [AT91SAM] Re: arm926ejs simple interrupts
>
> Hello everyone,
>
> I'm still trying to get the interrupts working. I have implemented the
> code from the examples that I got but so far they're still not working.
>
> When I check the registers with jtag I can see that there is an
> interrupt pending (return (pAic->AIC_IPR & (0x1 << irq_id));) but for
> some reason the active interrupt (return (pAic->AIC_ISR & (0x1 <<
> irq_id));) is always 0.
>
> When I look at the interrupt mask, to see which interrupts are enabled
> I can see that the PIT interrupt and the software interrupt are
> enabled (SYS value of AIC_IMR=1).
>
> I also tried to trigge the interrupts manually by writing 1 in
> AIC_ISCR but nothing happens.
>
> You can see my source code here:
> aic.c - http://pastebin.com/m61920f16 >
> aic.h - http://pastebin.com/m2653e9ef >
> main.c - http://pastebin.com/m51a7958b >
> main.h - http://pastebin.com/m63a31dd0 >
> pit.c - http://pastebin.com/m13cd9e02 >
> pit.h - http://pastebin.com/m54f75450 >
> CS1275.c(hw init) - http://pastebin.com/m2fe34e30
> The value of my CPSR is: 00100000 00000000 00000000 11010011
>
> I'm runing my code through debugger, does that disable interrupts?
>
> Let me know if more info about configuration and/or source code is
> needed.
>
> Thanks in advance,
> Jani
>
For the IAR compiler there is an intrisic function
__enable_interrupt();
For all interrupts. You can also set fiq and irq separately with
something like
__enable_irq()
__enable_fiq()
There are of course corresponding __disable commands
Hope this helps.
/johan

kumori0 skrev:
> Thanks, this should be the problem. I now have one very newbie
> question. How do I change the CPSR value in code? I can't find the
> memory location for it in AT91SAM9260 definitions where the memory
> addresses are. Do I have to use some assembly command?
>
> Jani
>
> --- In A... ,
> "ICLI, Bekir (EXT)"
> wrote:
> >
> > Hi Jani,
> >
> > Looking at your CPSR, you are masking I and F (bits 6-7) bits. That
> means, both fiq and irq interrupts are masked..
> >
> >
> > Mit freundlichem Gru/ Best regards
> > Bekir ICLI
> >
> >
> >
> >
> > ________________________________
> >
> > Von: A...
> [mailto:A... ] Im
> Auftrag von kumori0
> > Gesendet: Freitag, 4. April 2008 10:31
> > An: A...
> > Betreff: [AT91SAM] Re: arm926ejs simple interrupts
> >
> >
> >
> > Hello everyone,
> >
> > I'm still trying to get the interrupts working. I have implemented the
> > code from the examples that I got but so far they're still not working.
> >
> > When I check the registers with jtag I can see that there is an
> > interrupt pending (return (pAic->AIC_IPR & (0x1 << irq_id));) but for
> > some reason the active interrupt (return (pAic->AIC_ISR & (0x1 <<
> > irq_id));) is always 0.
> >
> > When I look at the interrupt mask, to see which interrupts are enabled
> > I can see that the PIT interrupt and the software interrupt are
> > enabled (SYS value of AIC_IMR=1).
> >
> > I also tried to trigge the interrupts manually by writing 1 in
> > AIC_ISCR but nothing happens.
> >
> > You can see my source code here:
> > aic.c - http://pastebin.com/m61920f16
> >
> > aic.h - http://pastebin.com/m2653e9ef
> >
> > main.c - http://pastebin.com/m51a7958b
> > >
> > main.h - http://pastebin.com/m63a31dd0
> > >
> > pit.c - http://pastebin.com/m13cd9e02
> >
> > pit.h - http://pastebin.com/m54f75450
> >
> > CS1275.c(hw init) - http://pastebin.com/m2fe34e30
>
> >
> >
> > The value of my CPSR is: 00100000 00000000 00000000 11010011
> >
> > I'm runing my code through debugger, does that disable interrupts?
> >
> > Let me know if more info about configuration and/or source code is
> > needed.
> >
> > Thanks in advance,
> > Jani
> >

--
Johan Ingvast, PhD, CEO BioServo Technologies AB
Mob. +46 70 34 34 498 http://www.bioservo.com
Pub. pgp sign.: http://www.md.kth.se/~ingvast/Ingvast_public_key.asc

Hello everyone,

I'm still trying to get the interrupts working. I have implemented the
code from the examples that I got but so far they're still not working.

When I check the registers with jtag I can see that there is an
interrupt pending (return (pAic->AIC_IPR & (0x1 << irq_id));) but for
some reason the active interrupt (return (pAic->AIC_ISR & (0x1 <<
irq_id));) is always 0.

When I look at the interrupt mask, to see which interrupts are enabled
I can see that the PIT interrupt and the software interrupt are
enabled (SYS value of AIC_IMR=1).

I also tried to trigge the interrupts manually by writing 1 in
AIC_ISCR but nothing happens.

You can see my source code here:
aic.c - http://pastebin.com/m61920f16
aic.h - http://pastebin.com/m2653e9ef
main.c - http://pastebin.com/m51a7958b
main.h - http://pastebin.com/m63a31dd0
pit.c - http://pastebin.com/m13cd9e02
pit.h - http://pastebin.com/m54f75450
CS1275.c(hw init) - http://pastebin.com/m2fe34e30

The value of my CPSR is: 00100000 00000000 00000000 11010011

I'm runing my code through debugger, does that disable interrupts?

Let me know if more info about configuration and/or source code is
needed.

Thanks in advance,
Jani
Thank you,

That helped a lot. I looked but I didn't look hard enough it seems.
I'm still trying to understand everything in C, I planed to learn more
about assembly after I can get the thing workng in c, because it
should be easier that way.

Does anyone know what

void ARM_reset(void);
void ARM_undef(void);
void ARM_swi(void);
void ARM_pAbort(void);
void ARM_dAbort(void);
void ARM_reserved(void);
void ARM_irq(void);
void ARM_fiq(void);

are for?

Jani

--- In A..., 42Bastian wrote:
>
> kumori0 schrieb:
> > I'm afraid I don't have IAR compiler, I'm using gcc, after Lynch's
> > tutorial. I have located the macros that should enable and disable the
> > interrupts in my hello world example, but I can't figure out what
> > exactly do they do.
>
> Did you look at the ARM assembly syntax ?
>
> The macros just copy the CPSR into key lock interrupts (and change to
> SYS-mode) or key into CPSR.
>
> --
> 42Bastian
>
> Note: SPAM-only account, direct mail to bs42@
>

Hi Jani,

They are the exception vector handlers, as it seems.
When there is, for example, a prefetch abort exception, the pc is loaded with the address 0xC.
And you probably have a branch to your ARM_pAbort() function at that address..

Mit freundlichem Gru/ Best regards
Bekir ICLI

________________________________

Von: A... [mailto:A...] Im Auftrag von kumori0
Gesendet: Dienstag, 8. April 2008 11:34
An: A...
Betreff: [AT91SAM] Re: arm926ejs simple interrupts

Thank you,

That helped a lot. I looked but I didn't look hard enough it seems.
I'm still trying to understand everything in C, I planed to learn more
about assembly after I can get the thing workng in c, because it
should be easier that way.

Does anyone know what

void ARM_reset(void);
void ARM_undef(void);
void ARM_swi(void);
void ARM_pAbort(void);
void ARM_dAbort(void);
void ARM_reserved(void);
void ARM_irq(void);
void ARM_fiq(void);

are for?

Jani

--- In A... , 42Bastian wrote:
>
> kumori0 schrieb:
> > I'm afraid I don't have IAR compiler, I'm using gcc, after Lynch's
> > tutorial. I have located the macros that should enable and disable the
> > interrupts in my hello world example, but I can't figure out what
> > exactly do they do.
>
> Did you look at the ARM assembly syntax ?
>
> The macros just copy the CPSR into key lock interrupts (and change to
> SYS-mode) or key into CPSR.
>
> --
> 42Bastian
>
> Note: SPAM-only account, direct mail to bs42@
>