This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

s3c2440a

dear all,
i have a arm board of s3c2440a from friendlyarm.
i am using IDE of metrowerks code warrior for arm developer suite v1.2.
i have started the PLL and timer. but i am unable to start interrupt.
i did all the initialisation for interrupt sam as the way it is shown in the sample program. i am attaching my code for the reference. i am posting in keil because i didnt get help in friendlyarm.net.
pls gothrough my code and help me out
thank you
regards
PS: in case of any queries pls let me know.
here is my code:

#include "def.h"
#include "option.h"
#include "2440addr.h"
#include "2440lib.h"
#include "2440slib.h"

#define EnableIrq(bit)          rINTMSK &= ~(bit)
#define DisableIrq(bit)         rINTMSK |= (bit)
#define EnableSubIrq(bit)       rINTSUBMSK &= ~(bit)
#define DisableSubIrq(bit)      rINTSUBMSK |= (bit)


void delay(unsigned int i);
void initialise(void);
void init(void);
void __irq timer0isr(void);
void MMU_SetFastBusMode(void);  //GCLK=HCLK
void MMU_SetAsyncBusMode(void); //GCLK=FCLK @(FCLK>=HCLK)
void HaltUndef(void);
void HaltSwi(void);
void HaltPabort(void);
void HaltDabort(void);
void HaltIrqabort(void);
void HaltFiqabort(void);

void ClearPending(int bit);
void ClearSubPending(int bit);
void enable_IRQ(void);


void __irq timer0isr(void)
{
 rGPBDAT = 0x141;

 rSRCPND = BIT_TIMER0;       //Clear pending bit
 rINTPND = BIT_TIMER0;
}


void delay(unsigned int i)
{
 unsigned int a,b;
 for(a=0;a<i;a++)
 b = 0;
}

void init(void)
{
 unsigned char mdiv,pdiv,sdiv;

 mdiv = 0x5c;   //settings for 405MHZ operation for M PLL
 pdiv = 0x01;
 sdiv = 0x01;
 rMPLLCON  = (mdiv << 12);
 rMPLLCON |= (pdiv << 4);
 rMPLLCON |= sdiv;

 mdiv = 2;
 pdiv = 0;
 rCLKDIVN  = (mdiv << 1); //FCLK = 405MHZ (MPLLCON setting), HCLK = FLK/4 = 101MHz, PCLK = HCLK/2 = 50MHz, UCLK = UPLLCON (as it is 48MHZ reqd)
 rCLKDIVN |= pdiv;

 mdiv = 0x38;   //settings for 405MHZ operation for M PLL
 pdiv = 0x02;
 sdiv = 0x02;
 rUPLLCON  = (mdiv << 12);
 rUPLLCON |= (pdiv << 4);
 rUPLLCON |= sdiv;

 pISR_UNDEF=(unsigned)HaltUndef;
 pISR_SWI  =(unsigned)HaltSwi;
 pISR_PABORT=(unsigned)HaltPabort;
 pISR_DABORT=(unsigned)HaltDabort;
 pISR_IRQ   =(unsigned)HaltIrqabort;
 pISR_FIQ   =(unsigned)HaltFiqabort;

 rINTMOD=0x00000000;      // All=IRQ mode
 rINTMSK=BIT_ALLMSK;      // All interrupt is masked.
 rPRIORITY = 0x00;
 rSUBSRCPND = 0x00000000;
 rINTSUBMSK = 0xffff;

 rCLKCON = 0xfffff0;

}

int Main(int argc, char **argv)
{
 int i;
 i = 0;

 for(i=0;i<100;i++)
  delay(10000);
 for(i=0;i<100;i++)
  delay(10000);
 for(i=0;i<100;i++)
  delay(10000);
 for(i=0;i<100;i++)
  delay(10000);
 for(i=0;i<100;i++)
  delay(10000);
 for(i=0;i<100;i++)
  delay(10000);

 init();

 //initialisation of the interrupt

 ClearPending(BIT_TIMER0);
 rPRIORITY   = 0x7f;
 pISR_IRQ    = (unsigned int)timer0isr;
 pISR_TIMER0 = (unsigned int)timer0isr;

 //timer initialisation:

 //Timer input clock Frequency = PCLK / {prescaler value+1} / {divider value}
 rTCFG0  = 0x000000ff;          //prescalar = 255 + 1
 rTCFG1  = 0x00000003;          //divide by 16
 rTCNTB0 = 30000;                       //down counter
 rTCMPB0 = 500;
 rTCON   = 0x00000000;
 rTCON   = 0x0000000b;          //AR INV UPDT START
 rTCON   = 0x00000009;

 EnableIrq(BIT_TIMER0);

 delay(100);

 //port initialisation:

 rGPBCON = 0x155556;            //tout0 = gpb0
 rGPBUP  = 0x7ff;                       //pullup disable
 rGPBDAT = 0x0000a0;


 //|AR|INV|UPDT|START|
 //if set inverter on,  when TCNT2<=TCMP2, TOUT is low,  TCNT2>TCMP2, TOUT is high
//if set inverter off, when TCNT2<=TCMP2, TOUT is high, TCNT2>TCMP2, TOUT is low

 for(;;)
  {
   i = 0;
  }
 return 0;
}


void HaltUndef(void)
{
        while(1);
}

void HaltSwi(void)
{
        while(1);
}

void HaltPabort(void)
{
        while(1);
}

void HaltDabort(void)
{
        while(1);
}

void HaltIrqabort(void)
{
        while(1);
}

void HaltFiqabort(void)
{
        while(1);
}


void ClearPending(int bit)
{
        register i;
        rSRCPND = bit;
        rINTPND = bit;
        i = rINTPND;
}

void ClearSubPending(int bit)
{
        register i;
        rSUBSRCPND = bit;
        i = rINTPND;
}

0