Sign in

username:

password:



Not a member?

Search lpc2000



Search tips

Subscribe to lpc2000



lpc2000 by Keywords

2106 | ADC | ARM7 | Atmel | Bootloader | CAN | CrossStudio | CrossWorks | DDS | ECos | Ethernet | ETM | FIFO | FLASH | FPGA | GCC | GDB | GNU | GNUARM | GPIO | I2C | IAP | IAR | JTAG | Kickstart | LCD | Linux | LPC | LPC-E2294 | LPC2000 | LPC2100 | LPC2104 | Lpc2106 | Lpc210x | LPC2114 | LPC2119 | LPC2124 | LPC2129 | Lpc2138 | LPC213x | LPC21xx | LPC2210 | LPC2212 | LPC2214 | LPC2292 | LPC2294 | LPC2xxx | LPC3128 | MCB2100 | Olimex | Philips | PWM | Rowley | RTC | RTOS | SPI | SSP | UART | UART0 | UART1 | ULINK | USB | Watchdog | Wiggler

Ads

Discussion Groups

Discussion Groups | LPC2000 | Re: Blinky Application Code with Timer Interrupt @ Address 0x00002000

Discussion group dedicated to the Philips LPC2000 family of ARM MCUs

Re: Blinky Application Code with Timer Interrupt @ Address 0x00002000 - SONNY - Mar 26 11:21:36 2008

Tom, Thanks for your time. I did set my IROM1 to 0x00002000-
0x00007E000 in Keil Target tab under Option. I'm new to remaping
handler into RAM, so can you give a code example or link where I can
use for my Blinky with Timer interrupt example.

-Sonny

--- In l...@yahoogroups.com, "Dezheng Tang" wrote:
>
> There is nothing wrong in your code. The problem is
> in your linker setting and/or remapping the interrupt
> vector.
>
> How did you build your application? If you have set
> code entry to 0x00020000, the polling code will run
> and your interrupt code won't. This is because, when
> the interrupt happens, the interrupt vector has not
> been set correctly yet.
>
> If you want to use the interrupt, you need to remap
> your handler to the RAM and ensure user interrupt
> vectors are active on top of the RAM.
>
> Tom
>
> --- In l...@yahoogroups.com, "SONNY" wrote:
> >
> > Here's the scenario:
> >
> > I have a USB Bootloader which runs at address 0x0 and a Blinky
> > application code with Timer0 interrupt at address starting at
> > 0x00002000.
> >
> > My Blinky code looks like this:
> > ------------------------------------------------------------------
-
> --
> > #include
> >
> > long timeval;
> >
> > void wait (void) { /* wait function */
> > unsigned long i;
> >
> > i = timeval;
> > while ((i + 10) != timeval); /* wait 100ms */
> > }
> >
> > /* Timer0 IRQ: Executed
> > periodically */
> > void T0_IRQHandler (void) __irq {
> >
> > timeval++;
> > T0IR = 1; /* Clear interrupt
> > flag */
> > VICVectAddr = 0; /* Acknowledge
> > Interrupt */
> > }
> >
> > int main (void) {
> > unsigned int j; /* LED var */
> >
> > PINSEL10=0; /* Disable ETM
interface
> */
> > FIO2DIR=0xFF; /* P1.16..23 defined
as
> > Outputs */
> > FIO2CLR=0xff;
> >
> > /* Enable and setup timer interrupt, start
> > timer */
> > T0MR0 = 149999; /* 1msec = 12000-
1
> at
> > 12.0 MHz */
> > T0MCR = 3; /* Interrupt and
> Reset
> > on MR0 */
> > T0TCR = 1; /* Timer0
> > Enable */
> > VICVectAddr4 = (unsigned long)T0_IRQHandler;/* Set Interrupt
> > Vector */
> > VICVectCntl4 = 15; /* use it for
> Timer0
> > Interrupt */
> > VICIntEnable = (1 << 4); /* Enable Timer0
> > Interrupt */
> >
> > while (1) { /* Loop forever */
> > for (j = 0x1; j < 0x80; j <<= 1) { /* Blink LED 0,1,2,3,4,5,6
> */
> > FIO2SET = j; /* Turn on LED */
> > wait (); /* call wait
> function
> > */
> > FIO2CLR = j; /* Turn off LED
*/
> > }
> > for (j = 0x8; j > 0x1; j >>=1 ) { /* Blink LED 7,6,5,4,3,2,1
*/
> > FIO2SET = j; /* Turn on LED */
> > wait (); /* call wait
> function
> > */
> > FIO2CLR = j; /* Turn off LED
*/
> > }
> > }
> > }
> > ------------------------------------------------------------------
-
> --
> >
> > I have a modified IRQ_Handler in StartUp.s:
> > ------------------------------------------------------------------
-
> --
> >
> > Vectors: LDR PC,Reset_Addr
> > LDR PC,Undef_Addr
> > LDR PC,SWI_Addr
> > LDR PC,PAbt_Addr
> > LDR PC,DAbt_Addr
> > NOP /* Reserved Vector
> */
> > LDR PC,IRQ_Addr
> > // LDR PC,[PC, #-0x0FF0] /* Vector from
> > VicVectAddr */
> > LDR PC,FIQ_Addr
> >
> > Reset_Addr: DD Reset_Handler
> > Undef_Addr: DD Undef_Handler?A
> > SWI_Addr: DD SWI_Handler?A
> > PAbt_Addr: DD PAbt_Handler?A
> > DAbt_Addr: DD DAbt_Handler?A
> > DD 0 /* Reserved
Address
> */
> > IRQ_Addr: DD IRQ_Handler
> > FIQ_Addr: DD FIQ_Handler?A
> >
> > IRQ_Handler:
> > SUB lr,lr,#4 /* Update the link register. */
> > STMFD sp!,{r0-r12,lr} /* Save The workspace plus the
> > current return*/
> > /* address lr_ mode into the
> stack.*/
> > MRS r1,spsr /* Save the spsr_mode into r1.*/
> > STMFD sp!,{r1} /* Save spsr.*/
> >
> > LDR R4, =0xffffff00 /* Load interrupt handler
> routine
> > address from VICADDRESS */
> >
> > LDR R0, [R4, #0]
> > MOV LR, PC /* set return address */
> > BX R0 /* call interrupt handler */
> >
> > STR R0, [R4 , #0] /* signal IRQ end to VIC */
> >
> > LDMFD sp!,{r1} /* Restore the saved spsr_mode
> into
> > r1. */
> > MSR spsr_cxsf,r1 /* Restore spsr_mode. */
> > LDMFD sp!,{r0-r12,pc}^ /* Return to the instruction
> > following... */
> > /* ...the exception
> interrupt.
> > */
> > ------------------------------------------------------------------
-
> --
> >
> > I can download Blinky Application Code using USB bootloader but
> > doesn't seem to run Blinky Application code after reset.
> >
> > I also have a version of Blinky App Code which uses "for loop" as
> > delay instead of a "timer" and it works fine (run after reset)
> with
> > USB bootloader.
> >
> > Not sure why Blinky with interrupt doesn't work with my USB
> > Bootloader. Any help/hints is much appreciated.
> >
> > -Sonny
>
------------------------------------



(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )