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;
}

Parents
  • dear sir thanks for reply
    but i didnt understand what you mentioned can you pls elaborate?
    is it totally different from microcontroller interrupt?
    i have assinged timer interrupt to timer interrupt address not irq and even if i assign to irq it still doesnt work. i am giving header file of all the addresses of register as follows:

    // INTERRUPT
    #define rSRCPND     (*(volatile unsigned *)0x4a000000)#define rINTMOD     (*(volatile unsigned *)0x4a000004)
    #define rINTMSK     (*(volatile unsigned *)0x4a000008)
    #define rPRIORITY   (*(volatile unsigned *)0x4a00000c)
    #define rINTPND     (*(volatile unsigned *)0x4a000010)
    #define rINTOFFSET  (*(volatile unsigned *)0x4a000014)#define rSUBSRCPND  (*(volatile unsigned *)0x4a000018)#define rINTSUBMSK  (*(volatile unsigned *)0x4a00001c)
    
    // PWM TIMER
    #define rTCFG0  (*(volatile unsigned *)0x51000000)      //Timer 0 configuration
    #define rTCFG1  (*(volatile unsigned *)0x51000004)      //Timer 1 configuration
    #define rTCON   (*(volatile unsigned *)0x51000008)      //Timer control
    #define rTCNTB0 (*(volatile unsigned *)0x5100000c)      //Timer count buffer 0
    #define rTCMPB0 (*(volatile unsigned *)0x51000010)      //Timer compare buffer 0
    #define rTCNTO0 (*(volatile unsigned *)0x51000014)      //Timer count observation 0
    #define rTCNTB1 (*(volatile unsigned *)0x51000018)      //Timer count buffer 1
    #define rTCMPB1 (*(volatile unsigned *)0x5100001c)      //Timer compare buffer 1
    #define rTCNTO1 (*(volatile unsigned *)0x51000020)      //Timer count observation 1
    #define rTCNTB2 (*(volatile unsigned *)0x51000024)      //Timer count buffer 2
    #define rTCMPB2 (*(volatile unsigned *)0x51000028)      //Timer compare buffer 2
    #define rTCNTO2 (*(volatile unsigned *)0x5100002c)      //Timer count observation 2
    #define rTCNTB3 (*(volatile unsigned *)0x51000030)      //Timer count buffer 3
    #define rTCMPB3 (*(volatile unsigned *)0x51000034)      //Timer compare buffer 3
    #define rTCNTO3 (*(volatile unsigned *)0x51000038)      //Timer count observation 3
    #define rTCNTB4 (*(volatile unsigned *)0x5100003c)      //Timer count buffer 4
    #define rTCNTO4 (*(volatile unsigned *)0x51000040)      //Timer count observation 4
    #define rMISCCR    (*(volatile unsigned *)0x56000080)   //Miscellaneous control
    #define rDCLKCON   (*(volatile unsigned *)0x56000084)   //DCLK0/1 control
    #define rEXTINT0   (*(volatile unsigned *)0x56000088)   //External interrupt control register 0
    #define rEXTINT1   (*(volatile unsigned *)0x5600008c)   //External interrupt control register 1
    #define rEXTINT2   (*(volatile unsigned *)0x56000090)   //External interrupt control register 2
    #define rEINTFLT0  (*(volatile unsigned *)0x56000094)   //Reserved
    #define rEINTFLT1  (*(volatile unsigned *)0x56000098)   //Reserved
    #define rEINTFLT2  (*(volatile unsigned *)0x5600009c)   //External interrupt filter control register 2
    #define rEINTFLT3  (*(volatile unsigned *)0x560000a0)   //External interrupt filter control register 3
    #define rEINTMASK  (*(volatile unsigned *)0x560000a4)   //External interrupt mask
    #define rEINTPEND  (*(volatile unsigned *)0x560000a8)   //External interrupt pending
    
    // Exception vector
    #define pISR_RESET              (*(unsigned *)(_ISR_STARTADDRESS+0x0))
    #define pISR_UNDEF              (*(unsigned *)(_ISR_STARTADDRESS+0x4))
    #define pISR_SWI                (*(unsigned *)(_ISR_STARTADDRESS+0x8))
    #define pISR_PABORT             (*(unsigned *)(_ISR_STARTADDRESS+0xc))
    #define pISR_DABORT             (*(unsigned *)(_ISR_STARTADDRESS+0x10))
    #define pISR_RESERVED   (*(unsigned *)(_ISR_STARTADDRESS+0x14))
    #define pISR_IRQ                (*(unsigned *)(_ISR_STARTADDRESS+0x18))
    #define pISR_FIQ                (*(unsigned *)(_ISR_STARTADDRESS+0x1c))
    // Interrupt vector
    #define pISR_EINT0              (*(unsigned *)(_ISR_STARTADDRESS+0x20))
    #define pISR_EINT1              (*(unsigned *)(_ISR_STARTADDRESS+0x24))
    #define pISR_EINT2              (*(unsigned *)(_ISR_STARTADDRESS+0x28))
    #define pISR_EINT3              (*(unsigned *)(_ISR_STARTADDRESS+0x2c))
    #define pISR_EINT4_7    (*(unsigned *)(_ISR_STARTADDRESS+0x30))
    #define pISR_EINT8_23   (*(unsigned *)(_ISR_STARTADDRESS+0x34))
    #define pISR_CAM                (*(unsigned *)(_ISR_STARTADDRESS+0x38))         // Added for 2440.
    #define pISR_BAT_FLT    (*(unsigned *)(_ISR_STARTADDRESS+0x3c))
    #define pISR_TICK               (*(unsigned *)(_ISR_STARTADDRESS+0x40))
    #define pISR_WDT_AC97           (*(unsigned *)(_ISR_STARTADDRESS+0x44))   //Changed to pISR_WDT_AC97 for 2440A
    #define pISR_TIMER0             (*(unsigned *)(_ISR_STARTADDRESS+0x48))
    #define pISR_TIMER1             (*(unsigned *)(_ISR_STARTADDRESS+0x4c))
    #define pISR_TIMER2             (*(unsigned *)(_ISR_STARTADDRESS+0x50))
    #define pISR_TIMER3             (*(unsigned *)(_ISR_STARTADDRESS+0x54))
    #define pISR_TIMER4             (*(unsigned *)(_ISR_STARTADDRESS+0x58))
    #define pISR_UART2              (*(unsigned *)(_ISR_STARTADDRESS+0x5c))
    #define pISR_LCD                (*(unsigned *)(_ISR_STARTADDRESS+0x60))
    #define pISR_DMA0               (*(unsigned *)(_ISR_STARTADDRESS+0x64))
    #define pISR_DMA1               (*(unsigned *)(_ISR_STARTADDRESS+0x68))
    #define pISR_DMA2               (*(unsigned *)(_ISR_STARTADDRESS+0x6c))
    #define pISR_DMA3               (*(unsigned *)(_ISR_STARTADDRESS+0x70))
    #define pISR_SDI                (*(unsigned *)(_ISR_STARTADDRESS+0x74))
    #define pISR_SPI0               (*(unsigned *)(_ISR_STARTADDRESS+0x78))
    #define pISR_UART1              (*(unsigned *)(_ISR_STARTADDRESS+0x7c))
    #define pISR_NFCON              (*(unsigned *)(_ISR_STARTADDRESS+0x80))         // Added for 2440.
    #define pISR_USBD               (*(unsigned *)(_ISR_STARTADDRESS+0x84))
    #define pISR_USBH               (*(unsigned *)(_ISR_STARTADDRESS+0x88))
    #define pISR_IIC                (*(unsigned *)(_ISR_STARTADDRESS+0x8c))
    #define pISR_UART0              (*(unsigned *)(_ISR_STARTADDRESS+0x90))
    #define pISR_SPI1               (*(unsigned *)(_ISR_STARTADDRESS+0x94))
    #define pISR_RTC                (*(unsigned *)(_ISR_STARTADDRESS+0x98))
    #define pISR_ADC                (*(unsigned *)(_ISR_STARTADDRESS+0x9c))
    
    
    // PENDING BIT
    #define BIT_EINT0               (0x1)
    #define BIT_EINT1               (0x1<<1)
    #define BIT_EINT2               (0x1<<2)
    #define BIT_EINT3               (0x1<<3)
    #define BIT_EINT4_7             (0x1<<4)
    #define BIT_EINT8_23    (0x1<<5)
    #define BIT_CAM                 (0x1<<6)          // Added for 2440.
    #define BIT_BAT_FLT             (0x1<<7)
    #define BIT_TICK                (0x1<<8)
    #define BIT_WDT_AC97    (0x1<<9)  // Changed from BIT_WDT to BIT_WDT_AC97 for 2440A
    #define BIT_TIMER0              (0x1<<10)
    #define BIT_TIMER1              (0x1<<11)
    #define BIT_TIMER2              (0x1<<12)
    #define BIT_TIMER3              (0x1<<13)
    #define BIT_TIMER4              (0x1<<14)
    
    #define BIT_SUB_ALLMSK  (0x7fff)                        //Changed from 0x7ff to 0x7fff for 2440A
    


    i have given certain registers as it was too lengthy to post

Reply
  • dear sir thanks for reply
    but i didnt understand what you mentioned can you pls elaborate?
    is it totally different from microcontroller interrupt?
    i have assinged timer interrupt to timer interrupt address not irq and even if i assign to irq it still doesnt work. i am giving header file of all the addresses of register as follows:

    // INTERRUPT
    #define rSRCPND     (*(volatile unsigned *)0x4a000000)#define rINTMOD     (*(volatile unsigned *)0x4a000004)
    #define rINTMSK     (*(volatile unsigned *)0x4a000008)
    #define rPRIORITY   (*(volatile unsigned *)0x4a00000c)
    #define rINTPND     (*(volatile unsigned *)0x4a000010)
    #define rINTOFFSET  (*(volatile unsigned *)0x4a000014)#define rSUBSRCPND  (*(volatile unsigned *)0x4a000018)#define rINTSUBMSK  (*(volatile unsigned *)0x4a00001c)
    
    // PWM TIMER
    #define rTCFG0  (*(volatile unsigned *)0x51000000)      //Timer 0 configuration
    #define rTCFG1  (*(volatile unsigned *)0x51000004)      //Timer 1 configuration
    #define rTCON   (*(volatile unsigned *)0x51000008)      //Timer control
    #define rTCNTB0 (*(volatile unsigned *)0x5100000c)      //Timer count buffer 0
    #define rTCMPB0 (*(volatile unsigned *)0x51000010)      //Timer compare buffer 0
    #define rTCNTO0 (*(volatile unsigned *)0x51000014)      //Timer count observation 0
    #define rTCNTB1 (*(volatile unsigned *)0x51000018)      //Timer count buffer 1
    #define rTCMPB1 (*(volatile unsigned *)0x5100001c)      //Timer compare buffer 1
    #define rTCNTO1 (*(volatile unsigned *)0x51000020)      //Timer count observation 1
    #define rTCNTB2 (*(volatile unsigned *)0x51000024)      //Timer count buffer 2
    #define rTCMPB2 (*(volatile unsigned *)0x51000028)      //Timer compare buffer 2
    #define rTCNTO2 (*(volatile unsigned *)0x5100002c)      //Timer count observation 2
    #define rTCNTB3 (*(volatile unsigned *)0x51000030)      //Timer count buffer 3
    #define rTCMPB3 (*(volatile unsigned *)0x51000034)      //Timer compare buffer 3
    #define rTCNTO3 (*(volatile unsigned *)0x51000038)      //Timer count observation 3
    #define rTCNTB4 (*(volatile unsigned *)0x5100003c)      //Timer count buffer 4
    #define rTCNTO4 (*(volatile unsigned *)0x51000040)      //Timer count observation 4
    #define rMISCCR    (*(volatile unsigned *)0x56000080)   //Miscellaneous control
    #define rDCLKCON   (*(volatile unsigned *)0x56000084)   //DCLK0/1 control
    #define rEXTINT0   (*(volatile unsigned *)0x56000088)   //External interrupt control register 0
    #define rEXTINT1   (*(volatile unsigned *)0x5600008c)   //External interrupt control register 1
    #define rEXTINT2   (*(volatile unsigned *)0x56000090)   //External interrupt control register 2
    #define rEINTFLT0  (*(volatile unsigned *)0x56000094)   //Reserved
    #define rEINTFLT1  (*(volatile unsigned *)0x56000098)   //Reserved
    #define rEINTFLT2  (*(volatile unsigned *)0x5600009c)   //External interrupt filter control register 2
    #define rEINTFLT3  (*(volatile unsigned *)0x560000a0)   //External interrupt filter control register 3
    #define rEINTMASK  (*(volatile unsigned *)0x560000a4)   //External interrupt mask
    #define rEINTPEND  (*(volatile unsigned *)0x560000a8)   //External interrupt pending
    
    // Exception vector
    #define pISR_RESET              (*(unsigned *)(_ISR_STARTADDRESS+0x0))
    #define pISR_UNDEF              (*(unsigned *)(_ISR_STARTADDRESS+0x4))
    #define pISR_SWI                (*(unsigned *)(_ISR_STARTADDRESS+0x8))
    #define pISR_PABORT             (*(unsigned *)(_ISR_STARTADDRESS+0xc))
    #define pISR_DABORT             (*(unsigned *)(_ISR_STARTADDRESS+0x10))
    #define pISR_RESERVED   (*(unsigned *)(_ISR_STARTADDRESS+0x14))
    #define pISR_IRQ                (*(unsigned *)(_ISR_STARTADDRESS+0x18))
    #define pISR_FIQ                (*(unsigned *)(_ISR_STARTADDRESS+0x1c))
    // Interrupt vector
    #define pISR_EINT0              (*(unsigned *)(_ISR_STARTADDRESS+0x20))
    #define pISR_EINT1              (*(unsigned *)(_ISR_STARTADDRESS+0x24))
    #define pISR_EINT2              (*(unsigned *)(_ISR_STARTADDRESS+0x28))
    #define pISR_EINT3              (*(unsigned *)(_ISR_STARTADDRESS+0x2c))
    #define pISR_EINT4_7    (*(unsigned *)(_ISR_STARTADDRESS+0x30))
    #define pISR_EINT8_23   (*(unsigned *)(_ISR_STARTADDRESS+0x34))
    #define pISR_CAM                (*(unsigned *)(_ISR_STARTADDRESS+0x38))         // Added for 2440.
    #define pISR_BAT_FLT    (*(unsigned *)(_ISR_STARTADDRESS+0x3c))
    #define pISR_TICK               (*(unsigned *)(_ISR_STARTADDRESS+0x40))
    #define pISR_WDT_AC97           (*(unsigned *)(_ISR_STARTADDRESS+0x44))   //Changed to pISR_WDT_AC97 for 2440A
    #define pISR_TIMER0             (*(unsigned *)(_ISR_STARTADDRESS+0x48))
    #define pISR_TIMER1             (*(unsigned *)(_ISR_STARTADDRESS+0x4c))
    #define pISR_TIMER2             (*(unsigned *)(_ISR_STARTADDRESS+0x50))
    #define pISR_TIMER3             (*(unsigned *)(_ISR_STARTADDRESS+0x54))
    #define pISR_TIMER4             (*(unsigned *)(_ISR_STARTADDRESS+0x58))
    #define pISR_UART2              (*(unsigned *)(_ISR_STARTADDRESS+0x5c))
    #define pISR_LCD                (*(unsigned *)(_ISR_STARTADDRESS+0x60))
    #define pISR_DMA0               (*(unsigned *)(_ISR_STARTADDRESS+0x64))
    #define pISR_DMA1               (*(unsigned *)(_ISR_STARTADDRESS+0x68))
    #define pISR_DMA2               (*(unsigned *)(_ISR_STARTADDRESS+0x6c))
    #define pISR_DMA3               (*(unsigned *)(_ISR_STARTADDRESS+0x70))
    #define pISR_SDI                (*(unsigned *)(_ISR_STARTADDRESS+0x74))
    #define pISR_SPI0               (*(unsigned *)(_ISR_STARTADDRESS+0x78))
    #define pISR_UART1              (*(unsigned *)(_ISR_STARTADDRESS+0x7c))
    #define pISR_NFCON              (*(unsigned *)(_ISR_STARTADDRESS+0x80))         // Added for 2440.
    #define pISR_USBD               (*(unsigned *)(_ISR_STARTADDRESS+0x84))
    #define pISR_USBH               (*(unsigned *)(_ISR_STARTADDRESS+0x88))
    #define pISR_IIC                (*(unsigned *)(_ISR_STARTADDRESS+0x8c))
    #define pISR_UART0              (*(unsigned *)(_ISR_STARTADDRESS+0x90))
    #define pISR_SPI1               (*(unsigned *)(_ISR_STARTADDRESS+0x94))
    #define pISR_RTC                (*(unsigned *)(_ISR_STARTADDRESS+0x98))
    #define pISR_ADC                (*(unsigned *)(_ISR_STARTADDRESS+0x9c))
    
    
    // PENDING BIT
    #define BIT_EINT0               (0x1)
    #define BIT_EINT1               (0x1<<1)
    #define BIT_EINT2               (0x1<<2)
    #define BIT_EINT3               (0x1<<3)
    #define BIT_EINT4_7             (0x1<<4)
    #define BIT_EINT8_23    (0x1<<5)
    #define BIT_CAM                 (0x1<<6)          // Added for 2440.
    #define BIT_BAT_FLT             (0x1<<7)
    #define BIT_TICK                (0x1<<8)
    #define BIT_WDT_AC97    (0x1<<9)  // Changed from BIT_WDT to BIT_WDT_AC97 for 2440A
    #define BIT_TIMER0              (0x1<<10)
    #define BIT_TIMER1              (0x1<<11)
    #define BIT_TIMER2              (0x1<<12)
    #define BIT_TIMER3              (0x1<<13)
    #define BIT_TIMER4              (0x1<<14)
    
    #define BIT_SUB_ALLMSK  (0x7fff)                        //Changed from 0x7ff to 0x7fff for 2440A
    


    i have given certain registers as it was too lengthy to post

Children