Hi all,
I am trying to use ep9302 without running linux, booting out of
redbhoot to my program.
I have written up some code which uses the latest newlib that uses the
reboot services for printf etc, with the latest gcc and binutils
comnpiled for arm-elf. I can print stuff out using printf but am stuck
at using the interrupt controller, so am guessing I am doing something
stupid?
I am trying (at the moment) to just fire off a timer 2 interrupt say
100 times per second which toggles the state of the LED on PE.0.
A simple version of the code is below, where the printfs all work, but
I never seem to get an interrupt (or least the LED never changes state)
Any ideas what I am (not) doing?
- - - - - - - - - - -
#include <stdio.h>
#define EP93XX_APB_BASE 0x80800000UL
#define GPIO_BASE (EP93XX_APB_BASE|0x00040000UL)
#define GPIO_PEDR (GPIO_BASE+0x20)
#define GPIO_PEDDR (GPIO_BASE+0x24)
#define IRQ_TIMER2 5
#define TIMER_BASE (EP93XX_APB_BASE|0x00010000UL)
#define TIMER2_LOAD (TIMER_BASE+0x20)
#define TIMER2_VALUE (TIMER_BASE+0x24)
#define TIMER2_CONTROL (TIMER_BASE+0x28)
#define TIMER2_CLEAR (TIMER_BASE+0x2C)
#define EP93XX_AHB_BASE 0x80000000
#define VIC1_BASE (EP93XX_AHB_BASE|0x000b0000)
#define VIC1_INT_SELECT (VIC1_BASE + 0x0c) /* 1 = FIQ, 0 = IRQ */
#define VIC1_INT_ENABLE (VIC1_BASE + 0x10) /* 1 = enable, 0 =
disable */
#define VIC1_INT_ENABLE_CLEAR (VIC1_BASE + 0x14)
#define VIC1_VECT_ADDR (VIC1_BASE + 0x30)
#define VIC1_DEF_VECT_ADDR (VIC1_BASE + 0x34)
#define VIC1_VECT_ADDR0 (VIC1_BASE + 0x100) /* 0 to 15 */
#define VIC1_VECT_CNTL0 (VIC1_BASE + 0x200) /* 0 to 15 */
void timer2_int() __attribute__((interrupt ("IRQ")));
void timer2_int()
{
/* tell VIC we are starting proecessing of thsi int */
unsigned int c = *((unsigned int *)(VIC1_VECT_ADDR));
/* toggle led */
*((unsigned int *)(GPIO_PEDR)) ^= 1;
/* tell VIC we have finished */
*((unsigned int *)(VIC1_VECT_ADDR)) = c;
}
void delay()
{
unsigned int i;
for(i=0;i<1000000;i++) { i=i; }
}
int main()
{
printf("starting\n");
/* init LED output and direction */
*((unsigned int *)(GPIO_PEDDR)) = 0xff;
*((unsigned int *)(GPIO_PEDR)) = 0x00;
printf("LEDs off\n");
/* setup the VIC */
/* disable this int ( using int 0 for timer 2) */
*((unsigned int *)(VIC1_INT_ENABLE_CLEAR)) = (1<<0);
/* set address of service routine */
*((unsigned int *)(VIC1_VECT_ADDR0)) = (unsigned int)timer2_int;
/* what interrtpt will generate this interrupt (and enableit)*/
*((unsigned int *)(VIC1_VECT_CNTL0)) = (0x20 | IRQ_TIMER2);
/* enable it */
*((unsigned int *)(VIC1_INT_ENABLE)) =(1<<0);
printf("VIC setup ok\n");
/* init timer 2 to interrupt 100 x per second */
*((unsigned int *)(TIMER2_CONTROL)) = 0x48;
*((unsigned int *)(TIMER2_LOAD)) = (508469/100)-1;
*((unsigned int *)(TIMER2_CONTROL)) = 0xc8;
printf("Timer 2 enabled\n");
while(1)
{
delay();
printf(".");
fflush(stdout);
}
}
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|