天嵌 ARM开发社区

 找回密码
 注册
查看: 3576|回复: 5

删除nand.c后又重新添加,无法点亮led,程序好像也没运行

[复制链接]
chenzhe805 发表于 2012-8-28 12:02:57 | 显示全部楼层 |阅读模式
     用天嵌的测试程序,删掉与led显示无关的文件后,led能点亮,把nand.c删除就不行了,再添加进来还是不行,这是怎么回事呢?
 楼主| chenzhe805 发表于 2012-8-28 12:05:57 | 显示全部楼层

Main.c

本帖最后由 chenzhe805 于 2012-8-28 12:07 编辑
  1. /****************************************************************
  2. NAME: u2440mon.c
  3. DESC: u2440mon entry point,menu,download
  4. ****************************************************************/
  5. #define        GLOBAL_CLK                1

  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include "def.h"
  9. #include "option.h"
  10. #include "2440addr.h"
  11. #include "2440lib.h"
  12. #include "2440slib.h"
  13. //#include "mmu.h"
  14. #include "profile.h"
  15. #include "memtest.h"
  16. /*
  17. extern char Image$$RO$$Limit[];
  18. extern char Image$$RO$$Base[];
  19. extern char Image$$RW$$Limit[];
  20. extern char Image$$RW$$Base[];
  21. extern char Image$$ZI$$Limit[];
  22. extern char Image$$ZI$$Base[];
  23. */
  24. void Isr_Init(void);
  25. void HaltUndef(void);
  26. void HaltSwi(void);
  27. void HaltPabort(void);
  28. void HaltDabort(void);
  29. void ClearMemory(void);


  30. void Clk0_Enable(int clock_sel);        
  31. void Clk1_Enable(int clock_sel);
  32. void Clk0_Disable(void);
  33. void Clk1_Disable(void);
  34. /*
  35. extern void Lcd_TFT_Init(void);
  36. extern void Lcd_TFT_Test( void ) ;
  37. extern void Test_Touchpanel(void) ;
  38. extern void Test_Adc(void) ;
  39. extern void KeyScan_Test(void) ;
  40. extern void RTC_Display(void) ;
  41. extern void Test_IrDA_Tx(void) ;
  42. extern void PlayMusicTest(void) ;
  43. extern void RecordTest( void ) ;
  44. extern void Test_Iic(void) ;
  45. extern void Test_SDI(void) ;
  46. extern void Camera_Test( void ) ;
  47. */
  48. volatile U32 downloadAddress;

  49. void (*restart)(void)=(void (*)(void))0x0;

  50. volatile unsigned char *downPt;
  51. volatile U32 downloadFileSize;
  52. volatile U16 checkSum;
  53. volatile unsigned int err=0;
  54. volatile U32 totalDmaCount;

  55. volatile int isUsbdSetConfiguration;

  56. int download_run=0;
  57. U32 tempDownloadAddress;
  58. int menuUsed=0;

  59. //extern char Image$$RW$$Limit[];
  60. //U32 *pMagicNum=(U32 *)Image$$RW$$Limit;
  61. int consoleNum;

  62. static U32 cpu_freq;
  63. static U32 UPLL;
  64. static void cal_cpu_bus_clk(void)
  65. {
  66.         U32 val;
  67.         U8 m, p, s;
  68.         
  69.         val = rMPLLCON;
  70.         m = (val>>12)&0xff;
  71.         p = (val>>4)&0x3f;
  72.         s = val&3;

  73.         //(m+8)*FIN*2 不要超出32位数!
  74.         FCLK = ((m+8)*(FIN/100)*2)/((p+2)*(1<<s))*100;
  75.         
  76.         val = rCLKDIVN;
  77.         m = (val>>1)&3;
  78.         p = val&1;        
  79.         val = rCAMDIVN;
  80.         s = val>>8;
  81.         
  82.         switch (m) {
  83.         case 0:
  84.                 HCLK = FCLK;
  85.                 break;
  86.         case 1:
  87.                 HCLK = FCLK>>1;
  88.                 break;
  89.         case 2:
  90.                 if(s&2)
  91.                         HCLK = FCLK>>3;
  92.                 else
  93.                         HCLK = FCLK>>2;
  94.                 break;
  95.         case 3:
  96.                 if(s&1)
  97.                         HCLK = FCLK/6;
  98.                 else
  99.                         HCLK = FCLK/3;
  100.                 break;
  101.         }
  102.         
  103.         if(p)
  104.                 PCLK = HCLK>>1;
  105.         else
  106.                 PCLK = HCLK;
  107.         
  108.         if(s&0x10)
  109.                 cpu_freq = HCLK;
  110.         else
  111.                 cpu_freq = FCLK;
  112.                
  113.         val = rUPLLCON;
  114.         m = (val>>12)&0xff;
  115.         p = (val>>4)&0x3f;
  116.         s = val&3;
  117.         UPLL = ((m+8)*FIN)/((p+2)*(1<<s));
  118.         UCLK = (rCLKDIVN&8)?(UPLL>>1):UPLL;
  119. }

  120. /*
  121. void Temp_function() { Uart_Printf("\nPlease input 1-11 to select test!!!\n"); }

  122. struct {
  123.         void (*fun)(void);
  124.         char *tip;
  125. }CmdTip[] = {
  126.                                 { Temp_function, "Please input 1-11 to select test" } ,
  127.                                 { BUZZER_PWM_Test, "Test PWM" } ,
  128.                                 { RTC_Display, "RTC time display" } ,
  129.                                 { Test_Adc, "Test ADC" } ,
  130.                                 { KeyScan_Test, "Test interrupt and key scan" } ,
  131.                                 { Test_Touchpanel, "Test Touchpanel" } ,
  132.                                 { Lcd_TFT_Test, "Test TFT LCD" } ,
  133.                                 { Test_Iic, "Test IIC EEPROM" } ,
  134.                                 { PlayMusicTest, "UDA1341 play music" } ,
  135.                                 { RecordTest, "UDA1341 record voice" } ,
  136.                                 { Test_SDI, "Test SD Card" } ,
  137.                                 { Camera_Test, "Test CMOS Camera"},
  138.                                 { 0, 0}                                                
  139.                         };

  140. */
  141. void Main(void)
  142. {
  143.         char *mode;
  144.         int i;
  145.         U8 key;
  146.         U32 mpll_val = 0 ;
  147.         //U32 divn_upll = 0 ;
  148.    
  149.         #if ADS10   
  150. //        __rt_lib_init(); //for ADS 1.0
  151.         #endif

  152.         Port_Init();
  153.         
  154.         Isr_Init();
  155.         
  156.         i = 2 ;        //don't use 100M!
  157.         switch ( i ) {
  158.         case 0:        //200
  159.                 key = 12;
  160.                 mpll_val = (92<<12)|(4<<4)|(1);
  161.                 break;
  162.         case 1:        //300
  163.                 key = 13;
  164.                 mpll_val = (67<<12)|(1<<4)|(1);
  165.                 break;
  166.         case 2:        //400
  167.                 key = 14;
  168.                 mpll_val = (92<<12)|(1<<4)|(1);
  169.                 break;
  170.         case 3:        //440!!!
  171.                 key = 14;
  172.                 mpll_val = (102<<12)|(1<<4)|(1);
  173.                 break;
  174.         default:
  175.                 key = 14;
  176.                 mpll_val = (92<<12)|(1<<4)|(1);
  177.                 break;
  178.         }
  179.         
  180.         //init FCLK=400M, so change MPLL first
  181.         ChangeMPllValue((mpll_val>>12)&0xff, (mpll_val>>4)&0x3f, mpll_val&3);
  182.         ChangeClockDivider(key, 12);
  183.         cal_cpu_bus_clk();
  184.         
  185.         consoleNum = 0;        // Uart 1 select for debug.
  186.         Uart_Init( 0,115200 );
  187.         Uart_Select( consoleNum );
  188.         
  189.         Beep(2000, 100);
  190.         
  191. //        Uart_SendByte('\n');
  192. //        Uart_Printf("<***************************************>\n");
  193. //        Uart_Printf("               TQ2440 Test Program\n");
  194. //        Uart_Printf("                www.embedsky.net\n");
  195. //        Uart_Printf("      Build time is: %s  %s\n", __DATE__ , __TIME__  );
  196. //        Uart_Printf("<***************************************>\n");

  197.         rMISCCR=rMISCCR&~(1<<3); // USBD is selected instead of USBH1
  198.         rMISCCR=rMISCCR&~(1<<13); // USB port 1 is enabled.


  199.         rDSC0 = 0x2aa;
  200.         rDSC1 = 0x2aaaaaaa;
  201.         //Enable NAND, USBD, PWM TImer, UART0,1 and GPIO clock,
  202.         //the others must be enabled in OS!!!
  203.         rCLKCON = 0xfffff0;

  204. //        MMU_Init();        //

  205.         pISR_SWI=(_ISR_STARTADDRESS+0xf0);        //for pSOS

  206.         Led_Display(0x66);
  207.         mode="DMA";

  208.         Clk0_Disable();
  209.         Clk1_Disable();
  210.         
  211.         mpll_val = rMPLLCON;

  212. //        Lcd_TFT_Init() ;                // LCD initial
  213.         
  214.         download_run=1; //The default menu is the Download & Run mode.

  215.         while(1)
  216.         {
  217.                 Led_Display(1);
  218.                
  219.         /*        
  220.                 U8 idx;
  221.                
  222.                 Uart_Printf("\nPlease select function : \n");        
  223.                 for(i=0; CmdTip[i].fun!=0; i++)
  224.                         Uart_Printf("%d : %s\n", i, CmdTip[i].tip);
  225.                 idx = Uart_GetIntNum_GJ() ;        
  226.                 if(idx<i)
  227.                 {
  228.                         (*CmdTip[idx].fun)();
  229.                         Delay(20);
  230.                         Uart_Init( 0,115200 );
  231.                 }
  232.         */        
  233.                         
  234.         }                  

  235. }

  236. void Isr_Init(void)
  237. {
  238.         pISR_UNDEF=(unsigned)HaltUndef;
  239.         pISR_SWI  =(unsigned)HaltSwi;
  240.         pISR_PABORT=(unsigned)HaltPabort;
  241.         pISR_DABORT=(unsigned)HaltDabort;
  242.         rINTMOD=0x0;          // All=IRQ mode
  243.         rINTMSK=BIT_ALLMSK;          // All interrupt is masked.
  244. }


  245. void HaltUndef(void)
  246. {
  247.         Uart_Printf("Undefined instruction exception!!!\n");
  248.         while(1);
  249. }

  250. void HaltSwi(void)
  251. {
  252.         Uart_Printf("SWI exception!!!\n");
  253.         while(1);
  254. }

  255. void HaltPabort(void)
  256. {
  257.         Uart_Printf("Pabort exception!!!\n");
  258.         while(1);
  259. }

  260. void HaltDabort(void)
  261. {
  262.         Uart_Printf("Dabort exception!!!\n");
  263.         while(1);
  264. }


  265. void ClearMemory(void)
  266. {
  267.         int memError=0;
  268.         U32 *pt;
  269.         
  270.         Uart_Printf("Clear Memory (%xh-%xh):WR",_RAM_STARTADDRESS,HEAPEND);

  271.         pt=(U32 *)_RAM_STARTADDRESS;
  272.         while((U32)pt < HEAPEND)
  273.         {
  274.                 *pt=(U32)0x0;
  275.                 pt++;
  276.         }
  277.         
  278.         if(memError==0)Uart_Printf("\b\bO.K.\n");
  279. }

  280. void Clk0_Enable(int clock_sel)        
  281. {        // 0:MPLLin, 1:UPLL, 2:FCLK, 3:HCLK, 4:PCLK, 5:DCLK0
  282.         rMISCCR = rMISCCR&~(7<<4) | (clock_sel<<4);
  283.         rGPHCON = rGPHCON&~(3<<18) | (2<<18);
  284. }
  285. void Clk1_Enable(int clock_sel)
  286. {        // 0:MPLLout, 1:UPLL, 2:RTC, 3:HCLK, 4:PCLK, 5:DCLK1        
  287.         rMISCCR = rMISCCR&~(7<<8) | (clock_sel<<8);
  288.         rGPHCON = rGPHCON&~(3<<20) | (2<<20);
  289. }
  290. void Clk0_Disable(void)
  291. {
  292.         rGPHCON = rGPHCON&~(3<<18);        // GPH9 Input
  293. }
  294. void Clk1_Disable(void)
  295. {
  296.         rGPHCON = rGPHCON&~(3<<20);        // GPH10 Input
  297. }

复制代码
亚瑟王 发表于 2012-8-28 12:09:37 | 显示全部楼层
亲,两个可能:
1、ADS的链接顺序不对;
2、你新增nand.c的代码编译后超过了4K容量。
 楼主| chenzhe805 发表于 2012-8-28 12:11:34 | 显示全部楼层
chenzhe805 发表于 2012-8-28 12:05

D:\My Documents\桌面\QQ截图20120828121304.png
亚瑟王 发表于 2012-8-28 14:05:56 | 显示全部楼层
chenzhe805 发表于 2012-8-28 12:11

看不到截图。
 楼主| chenzhe805 发表于 2012-8-28 14:53:50 | 显示全部楼层
原来是连接顺序不对,什么跟顺序有关系呢?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

i.MX8系列ARM cortex A53 M4 工控板上一条 /1 下一条

Archiver|手机版|小黑屋|天嵌 嵌入式开发社区 ( 粤ICP备11094220号 )

GMT+8, 2024-5-15 09:52 , Processed in 1.078118 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表