zoukankan      html  css  js  c++  java
  • ARM入门实践(一)----Mini6410上最简单的LED点灯裸机程序

    Mini6410上最简单的LED点灯裸机程序 :

    实验环境:

    根据友善教程,要用ADS,据说现在都不用这个了,但是为了打开友善给的mcp工程,就下了一个,Win7下弄上兼容模式和管理员权限,再下一个SecureCRT代替超级终端。

    一定要,把AXD也设置上。

    secureCRT的配置:选择Serial串口,波特率115200,端口号:USB转串(去驱动程序查端口号,今天插了一个COM4,一个COM5)

    实验步骤:

    配置好了以后,打开CodeWarrior编译mini6410-led.bin文件

    将bin文件直接复制到SD卡的images文件夹就行了, 然后配置FriendlyARM.ini文件

    6410有两种运行机制:一种是将程序直接从SD卡加载到内存运行,一种是将SD的镜像烧到NAND FLASH上启动,因为我的FLASH上系统有用,就先不覆盖了。

    第一种方法是烧到NAND FLASH上

    Action=install 
    OS= UserBin 
    UserBin‐Image=mini6410‐led.bin

    借助已经安装了SuperbootSD卡,可以把把mini6410‐led.bin 加载到内存中运行,步骤如下: 
    把mini6410‐led.bin 拷贝到SD卡的images 目录下, 
    打开FriendlyARM.ini配文件,修改如下关键定义: 

    第二种方法是直接在SD卡加载运行

    Action=run 
    OS= UserBin 
    UserBin‐Image=mini6410‐led.bin 
    UserBin‐StartAddress=50000000 

    通过读卡器拷贝到SD卡中——失败。。

    通过查找,发现配置文件FriendlyARM.int搞错了——不是直接添加是修改已有的东西(尤其UserBin)

    修改红色部分就行了,Action设置一下,安装还是运行?OS,换成UserBin,UserBin不能自己添加,是修改底部红色部分(要自己发现,友善的说明书真糙。。。。。)

    [plain] view plain copy
     
    1. #This line cannot be removed. by FriendlyARM(www.arm9.net)  
    2.   
    3. LCD-Mode = Yes  
    4. LCD-Type = S70  
    5.   
    6. CheckOneButton=No  
    7. <span style="color:#ff0000">Action=install  
    8. OS= Linux</span>  
    9.   
    10. VerifyNandWrite=No  
    11.   
    12. StatusType = Beeper| LED  
    13.   
    14. #################### Linux #####################  
    15. Linux-BootLoader = superboot-6410.bin  
    16. Linux-Kernel = Linux/zImage  
    17. Linux-CommandLine = root=ubi0:FriendlyARM-root ubi.mtd=2 rootfstype=ubifs init=nuxrc console=ttySAC0,115200  
    18. Linux-RootFs-InstallImage = Linux/rootfs_qtopia_qt4-SLC.ubi  
    19. Linux-RootFs-RunImage = Linux/rootfs_qtopia_qt4.ext3  
    20.   
    21. ################### Android ####################  
    22. Android-BootLoader = superboot-6410.bin  
    23. Android-Kernel = Android/azImage  
    24. Android-CommandLine = root=ubi0:FriendlyARM-root ubi.mtd=2 rootfstype=ubifs  init=nuxrc console=ttySAC0,115200 androidboot.console=s3c2410_serial0  
    25. Android-RootFs-InstallImage = Android/rootfs_android-SLC.ubi  
    26. Android-RootFs-RunImage = Android/rootfs_android.ext3  
    27.   
    28. ################### WindowsCE6 #################  
    29. WindowsCE6-Bootloader= superboot-6410.bin  
    30. WindowsCE6-BootLogo = WindowsCE6ootlogo.bmp  
    31. WindowsCE6-InstallImage = WindowsCE6enNK-i.bin  
    32. WindowsCE6-RunImage = WindowsCE6enNK-i.bin  
    33.   
    34. #################### Ubuntu #####################  
    35. Ubuntu-BootLoader = superboot-6410.bin  
    36. Ubuntu-Kernel = Ubuntu/uzImage  
    37. Ubuntu-CommandLine = root=ubi0:FriendlyARM-root ubi.mtd=2 rootfstype=ubifs  init=nuxrc console=ttySAC0,115200  
    38. Ubuntu-RootFs-InstallImage = Ubuntu/rootfs_ubuntu-SLC.ubi  
    39. Ubuntu-RootFs-RunImage = Ubuntu/rootfs_ubuntu.ext3  
    40.   
    41. <span style="color:#ff0000">############### UserBin #################  
    42. UserBin-Image=WindowsCE/NK-i.nb0  
    43. userBin-StartAddress=50100000</span>  



    main.c文件如下

    [cpp] view plain copy
     
    1. #include "utils.h"   
    2.    
    3. static void LedDelay(void)   
    4. {   
    5.       volatile unsigned int k;   
    6.       for(k = 0; k < 20000000; k++);   
    7. }   
    8.    
    9. int main(void)   
    10. {   
    11.    
    12.     Uart_Init();   
    13.     Port_Init();   
    14.     Uart_SendString(" Hello, Mini6410 ");   
    15.        
    16.     for(;;) {   
    17.       Led_Display(0x9); // 1001   
    18.   LedDelay();   
    19.       Led_Display(0x6); // 0110   
    20.   LedDelay();   
    21.     }   
    22.    
    23.     return 0;   
    24.    
    25. }   

    比较简单,一看就懂,直接靠bit控制4个LED灯。for循环里LED灯先两边后中间,一个”LED灯对对碰“,可以修改一下玩,比如改成流水线,改成跳跃,或者交替闪烁,可以分别使用,嫌来回插拔SD卡麻烦我就一次试了

    事实证明,最好分开测试:发现这个位操作的LED,0才是亮,1是灭;且LED4是低位,LED1是高位

    [plain] view plain copy
     
    1. void Led_Display(int data)  
    2.   
    3.    rGPKDAT = (rGPKDAT & ~(0xf<<4)) | ((data & 0xf)<<4);  


    [plain] view plain copy
     
    1. #include "utils.h"  
    2.   
    3.   
    4. static void LedDelay(void)  
    5. {  
    6.         volatile unsigned int k;  
    7.         for(k = 0; k < 20000000; k++);  
    8. }  
    9.   
    10.   
    11. int main(void)  
    12. {  
    13.   
    14.   
    15.     Uart_Init();  
    16.     Port_Init();  
    17.     Uart_SendString(" Hello, Mini6410 ");  
    18.       
    19.     for(;;) {  
    20.       
    21.     //LED对对碰  
    22.         Led_Display(0x9); // 1001  
    23.         LedDelay();  
    24.         Led_Display(0x6); // 0110  
    25.         LedDelay();  
    26.       
    27.     //流水灭灯  
    28.         LedDelay();      
    29.         LedDelay();  
    30.       
    31.         Led_Display(0x1);//0001  
    32.         LedDelay();  
    33.         Led_Display(0x2);//0010  
    34.         LedDelay();  
    35.         Led_Display(0x4);//0100  
    36.         LedDelay();  
    37.         Led_Display(0x8);//1000  
    38.         LedDelay();           
    39.         LedDelay();  
    40. <span style="white-space:pre">  </span>//流水亮灯  
    41. <pre name="code" class="plain">     Led_Display(0xe);//1110  
    42.         LedDelay();  
    43.         Led_Display(0xd);//1101  
    44.         LedDelay();  
    45.         Led_Display(0xb);//1011  
    46.         LedDelay();  
    47.         Led_Display(0x7);//0111  
    48.         LedDelay();           
    49.         LedDelay();</pre>//交替闪烁:1、3同闪,2、4同闪     Led_Display(0x5); // 0101     
    [plain] view plain copy
     
    1. <pre name="code" class="plain">         LedDelay();  </pre>        Led_Display(0xa); // 1010<br>  
    [plain] view plain copy
     
    1. <pre name="code" class="plain">         LedDelay();  </pre><pre name="code" class="plain"></pre><pre name="code" class="plain">         LedDelay();  </pre><pre name="code" class="plain">          LedDelay();  </pre>        }    return 0;}  

    再来个mini6410-led-v2.bin,或者v3,再给ini设置一下就ok了。

    [cpp] view plain copy
     
    1. <pre name="code" class="cpp"></pre>  

    完成效果

  • 相关阅读:
    从通胀说起
    科技见欲迷人眼
    吃货在西安 之 粉丝羊血泡馍
    祝母亲大人福如东海长流水,寿比南山不老松
    久违的蓝调北京
    调和生活前的问题
    《N2CMS实例教程》第四讲:Article Template Page
    《N2CMS实例教程》前言
    《N2CMS实例教程》第一讲:开发环境
    Microsoft Sync Framework 学习实例1文件同步
  • 原文地址:https://www.cnblogs.com/LiuDaohui0805/p/5270972.html
Copyright © 2011-2022 走看看