前两天写RTC中断 使用串口输出
发现程序会出现while(!(rUTRSTAT0 & 0x2));出不来的情况,但是中断是正常运作的
解决方法:
main函数增加:
U32 mpll_val = 0,consoleNum; Port_Init(); //定义在2440lib.c mpll_val = (92<<12)|(1<<4)|(1); //init FCLK=400M, ChangeMPllValue((mpll_val>>12)&0xff, (mpll_val>>4)&0x3f, mpll_val&3); (定义在2440lib.c) ChangeClockDivider(14, 12); //the result of rCLKDIVN [0:1:0:1] 3-0 bit (定义在2440lib.c) cal_cpu_bus_clk(); //HCLK=100M PCLK=50M consoleNum = 0; // Uart 1 select for debug. Uart_Init( 0,115200 ); // 定义在2440lib.c Uart_Select( consoleNum ); // 定义在2440lib.c
static U32 UPLL; static U32 cpu_freq;
void cal_cpu_bus_clk(void) { U32 val; U8 m, p, s; val = rMPLLCON; m = (val>>12)&0xff; p = (val>>4)&0x3f; s = val&3; //(m+8)*FIN*2 不要超出32位数! FCLK = ((m+8)*(FIN/100)*2)/((p+2)*(1<<s))*100; val = rCLKDIVN; m = (val>>1)&3; p = val&1; val = rCAMDIVN; s = val>>8; switch (m) { case 0: HCLK = FCLK; break; case 1: HCLK = FCLK>>1; break; case 2: if(s&2) HCLK = FCLK>>3; else HCLK = FCLK>>2; break; case 3: if(s&1) HCLK = FCLK/6; else HCLK = FCLK/3; break; } if(p) PCLK = HCLK>>1; else PCLK = HCLK; if(s&0x10) cpu_freq = HCLK; else cpu_freq = FCLK; val = rUPLLCON; m = (val>>12)&0xff; p = (val>>4)&0x3f; s = val&3; UPLL = ((m+8)*FIN)/((p+2)*(1<<s)); UCLK = (rCLKDIVN&8)?(UPLL>>1):UPLL; }
2440裸机串口调试 while(!(rUTRSTAT0 & 0x2));问题,布布扣,bubuko.com
2440裸机串口调试 while(!(rUTRSTAT0 & 0x2));问题
原文地址:http://blog.csdn.net/muyang_ren/article/details/36181579