We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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; }
hello all, i want to user timer0 interrupt. timer0 is working fine but i am unable to start timer0 interrupt pls help me thank you regards
hello everyone, pls reply. thank you
Take a look to MDK example located in folder: \Keil\ARM\Boards\Clabsys\LN2440SCB\Blinky\
thanks for replay i tried using the same program but still it is not working. can you guide in writing isr for arm? am i doing mistake in writing isr? because my timer is wroking fine. pls help me thank you
I think that you probably do not have remapping setup correctly and that you do not have interrupt vectors at addresses from 0.
I suggest you get Clabsys example working first as it is for same Samsung chip, except it perhaps uses different memory (external SDRAM) than you. In the process you will find out what was missing in you program.
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
hello everyone, can you pls help me out in my problem? thank you all
hello everyone, has anyone worked on arm9 of s3c2440a? pls suggest me some documents for it. so that i can solve my problem thank you
http://www.keil.com/dd/chip/4277.htm provides a copy of the User Manual
Have you looked on the manufacturer's (Samsung?) website?
hello andy, thankx for reply. i have its user manual but i didnt get info about interrupt much except its register. is it so that interrupt in arm9 works only on OS platform? because i have not installed OS on arm board and on samsung i couldnt found the info nor do they send me info. so pls clr my doubt. thank you
Think about it: the processor just executes instructions - it has absolutely no idea whatsoever whether those instructions happen to form part of an OS or anything else!
dear sir, i read about its nand memory that it loads code to 1st 4kB of sdram in s3c2440a and executes from there but they didnt mention about interrupt location. do i have to shift to any interrupt location then how? interrupts are executed in priviledged mode. but i m writing code in 'C' so i think i dont have to do this switching am i right? i think its related to place interrupts at proper location but how? pls guide me thank you regards
It's pleasant for me to contact you in order to make a consult about a problem I had with the memory adress mapping, i would like to inquire if you made the .icf file for IAR embebed workbrench (for the mini2440 version) or you are able to give support about this topic. If you have any consultation, please contact me. Thank you for your time and Best Regards