1. kppp

    Thread Starter Member

    Apr 23, 2008
    14
    0
    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:
    Code ( (Unknown Language)):
    1. #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=HCLKvoid 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;}
     
  2. bertus

    Administrator

    Apr 5, 2008
    15,646
    2,345
    Hello,

    Please format the code.
    It is now one long line.
    Use the code tags for better readability.

    Bertus
     
  3. kppp

    Thread Starter Member

    Apr 23, 2008
    14
    0
    here is my code:

    Code ( (Unknown Language)):
    1.  
    2.  
    3. #include "def.h"
    4. #include "option.h"
    5. #include "2440addr.h"
    6. #include "2440lib.h"
    7. #include "2440slib.h"
    8.  
    9. #define EnableIrq(bit)          rINTMSK &= ~(bit)
    10. #define DisableIrq(bit)         rINTMSK |= (bit)
    11. #define EnableSubIrq(bit)       rINTSUBMSK &= ~(bit)
    12. #define DisableSubIrq(bit)      rINTSUBMSK |= (bit)
    13.  
    14.  
    15. void delay(unsigned int i);
    16. void initialise(void);
    17. void init(void);
    18. void __irq timer0isr(void);
    19. void MMU_SetFastBusMode(void);  //GCLK=HCLK
    20. void MMU_SetAsyncBusMode(void); //GCLK=FCLK @(FCLK>=HCLK)
    21. void HaltUndef(void);
    22. void HaltSwi(void);
    23. void HaltPabort(void);
    24. void HaltDabort(void);
    25. void HaltIrqabort(void);
    26. void HaltFiqabort(void);
    27.  
    28. void ClearPending(int bit);
    29. void ClearSubPending(int bit);
    30. void enable_IRQ(void);
    31.  
    32.  
    33. void __irq timer0isr(void)
    34. {
    35.  rGPBDAT = 0x141;
    36.  
    37.  rSRCPND = BIT_TIMER0;       //Clear pending bit
    38.  rINTPND = BIT_TIMER0;
    39. }
    40.  
    41.  
    42. void delay(unsigned int i)
    43. {
    44.  unsigned int a,b;
    45.  for(a=0;a<i;a++)
    46.  b = 0;
    47. }
    48.  
    49. void init(void)
    50. {
    51.  unsigned char mdiv,pdiv,sdiv;
    52.  
    53.  mdiv = 0x5c;   //settings for 405MHZ operation for M PLL
    54.  pdiv = 0x01;
    55.  sdiv = 0x01;
    56.  rMPLLCON  = (mdiv << 12);
    57.  rMPLLCON |= (pdiv << 4);
    58.  rMPLLCON |= sdiv;
    59.  
    60.  mdiv = 2;
    61.  pdiv = 0;
    62.  rCLKDIVN  = (mdiv << 1); //FCLK = 405MHZ (MPLLCON setting), HCLK = FLK/4 = 101MHz, PCLK = HCLK/2 = 50MHz, UCLK = UPLLCON (as it is 48MHZ reqd)
    63.  rCLKDIVN |= pdiv;
    64.  
    65.  mdiv = 0x38;   //settings for 405MHZ operation for M PLL
    66.  pdiv = 0x02;
    67.  sdiv = 0x02;
    68.  rUPLLCON  = (mdiv << 12);
    69.  rUPLLCON |= (pdiv << 4);
    70.  rUPLLCON |= sdiv;
    71.  
    72.  pISR_UNDEF=(unsigned)HaltUndef;
    73.  pISR_SWI  =(unsigned)HaltSwi;
    74.  pISR_PABORT=(unsigned)HaltPabort;
    75.  pISR_DABORT=(unsigned)HaltDabort;
    76.  pISR_IRQ   =(unsigned)HaltIrqabort;
    77.  pISR_FIQ   =(unsigned)HaltFiqabort;
    78.  
    79.  rINTMOD=0x00000000;      // All=IRQ mode
    80.  rINTMSK=BIT_ALLMSK;      // All interrupt is masked.
    81.  rPRIORITY = 0x00;
    82.  rSUBSRCPND = 0x00000000;
    83.  rINTSUBMSK = 0xffff;
    84.  
    85.  rCLKCON = 0xfffff0;
    86.  
    87. }
    88.  
    89. int Main(int argc, char **argv)
    90. {
    91.  int i;
    92.  i = 0;
    93.  
    94.  for(i=0;i<100;i++)
    95.   delay(10000);
    96.  for(i=0;i<100;i++)
    97.   delay(10000);
    98.  for(i=0;i<100;i++)
    99.   delay(10000);
    100.  for(i=0;i<100;i++)
    101.   delay(10000);
    102.  for(i=0;i<100;i++)
    103.   delay(10000);
    104.  for(i=0;i<100;i++)
    105.   delay(10000);
    106.  
    107.  init();
    108.  
    109.  //initialisation of the interrupt
    110.  
    111.  ClearPending(BIT_TIMER0);
    112.  rPRIORITY   = 0x7f;
    113.  pISR_IRQ    = (unsigned int)timer0isr;
    114.  pISR_TIMER0 = (unsigned int)timer0isr;
    115.  
    116.  //timer initialisation:
    117.  
    118.  //Timer input clock Frequency = PCLK / {prescaler value+1} / {divider value}
    119.  rTCFG0  = 0x000000ff;          //prescalar = 255 + 1
    120.  rTCFG1  = 0x00000003;          //divide by 16
    121.  rTCNTB0 = 30000;                       //down counter
    122.  rTCMPB0 = 500;
    123.  rTCON   = 0x00000000;
    124.  rTCON   = 0x0000000b;          //AR INV UPDT START
    125.  rTCON   = 0x00000009;
    126.  
    127.  EnableIrq(BIT_TIMER0);
    128.  
    129.  delay(100);
    130.  
    131.  //port initialisation:
    132.  
    133.  rGPBCON = 0x155556;            //tout0 = gpb0
    134.  rGPBUP  = 0x7ff;                       //pullup disable
    135.  rGPBDAT = 0x0000a0;
    136.  
    137.  
    138.  //|AR|INV|UPDT|START|
    139.  //if set inverter on,  when TCNT2<=TCMP2, TOUT is low,  TCNT2>TCMP2, TOUT is high
    140. //if set inverter off, when TCNT2<=TCMP2, TOUT is high, TCNT2>TCMP2, TOUT is low
    141.  
    142.  for(;;)
    143.   {
    144.    i = 0;
    145.   }
    146.  return 0;
    147. }
    148.  
    149.  
    150. void HaltUndef(void)
    151. {
    152.         while(1);
    153. }
    154.  
    155. void HaltSwi(void)
    156. {
    157.         while(1);
    158. }
    159.  
    160. void HaltPabort(void)
    161. {
    162.         while(1);
    163. }
    164.  
    165. void HaltDabort(void)
    166. {
    167.         while(1);
    168. }
    169.  
    170. void HaltIrqabort(void)
    171. {
    172.         while(1);
    173. }
    174.  
    175. void HaltFiqabort(void)
    176. {
    177.         while(1);
    178. }
    179.  
    180.  
    181. void ClearPending(int bit)
    182. {
    183.         register i;
    184.         rSRCPND = bit;
    185.         rINTPND = bit;
    186.         i = rINTPND;
    187. }
    188.  
    189. void ClearSubPending(int bit)
    190. {
    191.         register i;
    192.         rSUBSRCPND = bit;
    193.         i = rINTPND;
    194. }
    195.  
    196.