void Test_IdleModeHard(void) { int i,j; MMU_SetAsyncBusMode(); //ARM920T should be in the async. bus mode. Uart_Printf("[IDLE Mode Hard Test with Timer0]\n"); Uart_Printf("S3C2440 will also wake up by EINT0 falling edge.\n"); Uart_TxEmpty(1); //Wait until UART0 Tx buffer empty. rGPFCON=rGPFCON & ~(3<<0)|(2<<0); //PF0=EINT0 rEXTINT0=rEXTINT0&(7<<0)|(0x2<<0); //EINT0=falling edge triggered rSRCPND = BIT_EINT0; rINTPND = BIT_EINT0; t0cnt=0;t1cnt=0; pISR_TIMER0=(U32)Timer0Int; pISR_TIMER1=(U32)Timer1Int; pISR_EINT0=(U32)Eint0Int; rTCFG0=0x0; //PRESC01=1,PRESC234=1 rTCFG1=0x0; //TIMER0,1,2,3,4,5= 1/2 rTCNTB0=65535; rTCNTB1=2570; rTCON=0xa0a; //T0,T1=manualUpdate,interval mode rTCON=0x909; //Start T0,T1. //rTCON=0x00a; //rTCON=0x009; rINTMSK=~(BIT_EINT0|BIT_TIMER0|BIT_TIMER1); for(i=0;i<10000;i++) { rCLKCON|=(1<<2); //enter IDLE mode. //wait until S3C2400X enters IDLE mode. //wait EINT0 interrupt or RTC alarm interrupt for(j=0;j<10;j++); rCLKCON&=~(1<<2); //turn-off IDLE bit. IDLE bit should be turned off after wake-up. if(i%100==0)Uart_Printf("#"); } rTCON=0x0; //turn the timer off rINTMSK=BIT_ALLMSK; Uart_Printf("\nt0cnt=%d,t1cnt=%d(t0cnt+t1cnt>=10000)\n",t0cnt,t1cnt); Uart_Printf("Return to Normal Mode.\n"); }
//========================[ HCLK, PCLK ]=========================== void ChangeClockDivider(int hdivn,int pdivn) { // hdivn,pdivn FCLK:HCLK:PCLK // 0,0 1:1:1 // 0,1 1:1:2 // 1,0 1:2:2 // 1,1 1:2:4 rCLKDIVN = (hdivn<<1) | pdivn; if(hdivn) MMU_SetAsyncBusMode(); else MMU_SetFastBusMode(); }
void Test_IdleMode(void) { int i; // int extintMode; MMU_SetAsyncBusMode(); //ARM920T should be in the async bus mode //because FCLK is used for ARM920T in the async bus mode. Uart_Printf("[IDLE Mode Test]\n"); Uart_Printf("After 10 seconds, S3C2440 will wake up by RTC alarm interrupt.\n"); Uart_Printf("S3C2440 will also wake up by EINT0.\n"); //PWR_Lcd_Tft_16Bit_240320_On(); //PWR_StartIIS(); //PWR_StartTimer(); Uart_TxEmpty(1); //Wait until UART0 Tx buffer empty. rGPFCON=rGPFCON & ~(3<<0)|(2<<0); //PF0=EINT0 rEXTINT0=rEXTINT0&(7<<0)|(0x2<<0); //EINT0=falling edge triggered pISR_EINT0=(U32)Eint0Int; pISR_RTC=(U32)AlarmInt; rSRCPND = BIT_EINT0|BIT_RTC; //to clear the previous pending states rINTPND = BIT_EINT0|BIT_RTC; rINTMSK=~(BIT_EINT0|BIT_RTC); SetAlarmWakeUp(); rRTCCON = 0x0; // R/W disable, but interrupt will be generated. rCLKCON|=(1<<2); //enter IDLE mode. for(i=0;i<10;i++); //wait until S3C2400X enters IDLE mode. //wait EINT0 interrupt or RTC alarm interrupt rCLKCON&=~(1<<2); //turn-off IDLE bit. IDLE bit should be turned off after wake-up. Uart_Printf("Return to Normal Mode.\n"); rINTMSK=BIT_ALLMSK; }
//************************[ HCLK, PCLK ]*************************** void ChangeClockDivider(int hdivn_val,int pdivn_val) { int hdivn=2, pdivn=0; // hdivn_val (FCLK:HCLK)ratio hdivn // 11 1:1 (0) // 12 1:2 (1) // 13 1:3 (3) // 14 1:4 (2) // pdivn_val (HCLK:PCLK)ratio pdivn // 11 1:1 (0) // 12 1:2 (1) switch(hdivn_val) { case 11: hdivn=0; break; case 12: hdivn=1; break; case 13: hdivn=3; break; case 16: hdivn=3; break; case 14: hdivn=2; break; case 18: hdivn=2; break; } switch(pdivn_val) { case 11: pdivn=0; break; case 12: pdivn=1; break; } //Uart_Printf("Clock division change [hdiv:%x, pdiv:%x]\n", hdivn, pdivn); rCLKDIVN = (hdivn<<1) | pdivn; //Uart_Printf("rCLKDIVN:%x]\n", rCLKDIVN); switch(hdivn_val) { case 16: // when 1, HCLK=FCLK/6. rCAMDIVN = (rCAMDIVN & ~(3<<8)) | (1<<8); break; case 18: // when 1, HCLK=FCLK/8. rCAMDIVN = (rCAMDIVN & ~(3<<8)) | (1<<9); break; } //Uart_Printf("rCAMDIVN:%x]\n", rCAMDIVN); if(hdivn!=0) MMU_SetAsyncBusMode(); else MMU_SetFastBusMode(); }
void Test_MMUIdleMode(void) { int i; // int extintMode; MMU_SetAsyncBusMode(); //ARM920T should be in the async. Bus mode. Uart_Printf("[MMU IDLE Mode Test]\n"); Uart_Printf("This routine tests MMU registser7:Wait for interrupt function.\n"); Uart_Printf("After 10 seconds, S3C2440 will wake up by RTC alarm interrupt.\n"); Uart_Printf("S3C2440 will also wake up by EINT0.\n"); Uart_TxEmpty(1); //Wait until UART0 Tx buffer empty. rGPFCON=rGPFCON & ~(3<<0)|(2<<0); //PF0=EINT0 rEXTINT0=rEXTINT0&(7<<0)|(0x2<<0); //EINT0=falling edge triggered pISR_EINT0=(U32)Eint0Int; pISR_RTC=(U32)AlarmInt; rSRCPND = BIT_EINT0|BIT_RTC; //to clear the previous pending states rINTPND = BIT_EINT0|BIT_RTC; rINTMSK=~(BIT_EINT0|BIT_RTC); //rINTMSK=~(BIT_RTC); //rINTMSK=BIT_ALLMSK; SetAlarmWakeUp(); rRTCCON = 0x0; // R/W disable, but interrupt will be generated. MMU_WaitForInterrupt(); //wait until S3C2400X enters IDLE mode. //wait EINT0 interrupt or RTC alarm interrupt for(i=0;i<10;i++); Uart_Printf("Return to Normal Mode.\n"); rINTMSK=BIT_ALLMSK; }