Atmel website | ARM Community | AVR freaks | Technical Support
Banner
Welcome to AT91SAM Community Forum
http://www.at91.com/samphpbb/

Simulating interrupts with AIC_ISCR on AT91SAM7X
http://www.at91.com/samphpbb/viewtopic.php?f=15&t=18481
Page 1 of 1

Author:  amuses [ Mon Aug 10, 2009 10:13 pm ]
Post subject:  Simulating interrupts with AIC_ISCR on AT91SAM7X

Hi, I am trying to generate an IRQ on the at91sam7x using the AIC, however the AIC_ISCR (Interrupt Set Command Register) does not seem to work. I expect that writing to this register would trigger an interrupt from the given PID, as long as that PID is in edge-sensitive mode (see the at91sam7x preliminary for the AIC's operation details). However, the following code does not work as expected, (i.e. Line @ 4.A should not run! )

What's the deal?

Code:
/*
* Script that SHOULD generate an interrupt using the AIC,
* but WHY doesn't it?
* For at91sam7x256 ( olimex sam7-ex256 )
*/

.set AIC_BASE, 0xFFFFf000
@interrupt enable command
.set AIC_IVR,  0x0100
.set AIC_FVR,  0x0104
.set AIC_IMR,  0x0110
.set AIC_CISR, 0x0114
.set AIC_SMR3, 0x000C
.set AIC_SVR3, 0x008C

.set AIC_IECR, 0x0120
.set AIC_ICCR, 0x0128
.set AIC_ISCR, 0x012C
.set AIC_EOICR,0x0130
.set AIC_FFER, 0x0140

.set PIO_B_BASE, 0xFFFFf600
@ PIO enable/disable/status registers
.set PIO_PER, 0x0000
.set PIO_PDR, 0x0004
.set PIO_PSR, 0x0008
@ Output enable/disable/status registers
.set PIO_OER, 0x0010
.set PIO_ODR, 0x0014
.set PIO_OSR, 0x0018
@ Set/clear/status of output data
.set PIO_SODR, 0x0030
.set PIO_CODR, 0x0034
.set PIO_ODSR, 0x0038
@ Pin data status
.set PIO_PDSR, 0x003C
@ Interrupt enable
.set PIO_IER,  0x0040


.global _vec_reset

/* Initial vector table */
_vec_reset: b _init_reset
_vec_undef: b _irq_handler
_vec_swi: b _irq_handler
_vec_pabt: b _irq_handler
_vec_dabt: b _irq_handler
_vec_rsv: b _irq_handler
_vec_irq: b _irq_handler
_vec_fiq: b _irq_handler


_init_reset:
@ 1. Enable interrupts from peripheral 3 on AIC
ldr r0, =AIC_BASE
@ 1.1 Set Mode
ldr r1, =0x67 @ Mode will be: Positive edge triggered, Priority 7 (max)
str r1, [r0, #+AIC_SMR3]
@ 1.2 Enable interrupts on PID3
ldr r1, =(1<<3)
str r1, [r0, #+AIC_IECR]

@ 2. Enable interrupts of all kinds in current processor mode (default is supervisor mode after reset)
cpsie afi

@ 3.A Simulate an interrupt from peripheral 3
str r1, [r0, #+AIC_ISCR]
@ 3.B Do a software interrupt instead if you wish to confirm that [4.B] works
@ swi 69

@ 4.A Loop endlessly (should not be reached)
spin: b spin

@ 4.B IRQ Handler: Blink the connected LED endlessly
_irq_handler:
@ 4.B.1 Enable PIO output on PB21
ldr r0, =PIO_B_BASE
ldr r1, =(1<<21)
str r1, [r0, #+PIO_PER]
str r1, [r0, #+PIO_CODR]
str r1, [r0, #+PIO_OER]
@ 4.B.2 Strobe the LED endlessly
strobe_loop:
bl delay
str r1, [r0, #+PIO_SODR] @ high
bl delay
str r1, [r0, #+PIO_CODR] @ low
b strobe_loop

@ X. "delay" subroutine
delay:
ldr r3, =1000
delay_loop:
add r3, r3, #-1
cmp r3, #0
movle pc, r14 @ return from bl
b delay_loop


Hm?

Author:  amuses [ Sun Aug 23, 2009 5:17 am ]
Post subject:  Re: Simulating interrupts with AIC_ISCR on AT91SAM7X

I figured out how to make interrupts work using AIC_ISCR, and/or the Periodic Interval Timer (PIT). My problem was that the "cpsie" instruction I was trying to use is invalid on the ARM7TDMI, so I had to use msr instead.

For more details, see http://blog.muse.it.cx/?p=9 or PM me.

Author:  injioncloud [ Tue Apr 05, 2011 4:45 pm ]
Post subject:  Re: Simulating interrupts with AIC_ISCR on AT91SAM7X

Hello Friend!!!

I am also looking for some similar project and can you send me the source code?? and instruction on how to put it onto SAM7-EX256?

I am familiar with C program but not assembly program!!

Thanks,
Santhosh

Page 1 of 1 All times are UTC + 1 hour [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/