OpenVINOTM,给你看得见的未来!>>
电子产品世界 » 论坛首页 » 综合技术 » 基础知识 » 2132,MCU 大家好!我只想把2132当作一个高档MCU来用,我的问题见正文

共2条 1/1 1 跳转至

2132,MCU 大家好!我只想把2132当作一个高档MCU来用,我的问题见正文!

院士
2006-12-22 22:43:00    评分
2132,MCU 大家好!我只想把2132当作一个高档MCU来用,我的问题见正文!



关键词: 大家     想把     当作     一个     高档     来用     我的     问题         

院士
2006-12-22 22:43:00    评分
2楼
问 我如何设置启动?

我只想作一个高档的MCU来运行,没有嵌入式系统!

请问:

我如何设置启动?

以及如何做修改以及修改那里?

原文件如下:

;/****************************************Copyright (c)**************************************************
;**                               Guangzou ZLG-MCU Development Co.,LTD.
;**                                      graduate school
;**                                 http://www.zlgmcu.com
;**
;**--------------File Info-------------------------------------------------------------------------------
;** File name:             Startup.s
;** Last modified Date:  2004-09-17
;** Last Version:         1.0
;** Descriptions:         The start up codes for LPC2100, including the initializing codes for the entry point of exceptions and the stacks of user tasks.
;**                Every project should have a independent copy of this file for related modifications
;**------------------------------------------------------------------------------------------------------
;** Created by:             Chenmingji
;** Created date:           2004-02-02
;** Version:                1.0
;** Descriptions:         The original version
;**
;**------------------------------------------------------------------------------------------------------
;** Modified by:         Chenmingji
;** Modified date:        2004-09-17
;** Version:                1.01
;** Descriptions:         Modified the bus setting to adapt for many common situations
;**
;**------------------------------------------------------------------------------------------------------
;** Modified by:         Chenmingji
;** Modified date:        2004-09-17
;** Version:                1.02
;** Descriptions:         Added codes to support the enciphering of the chip
;**
;**------------------------------------------------------------------------------------------------------
;** Modified by:         Chenmingji
;** Modified date:        2004-09-17
;** Version:                1.04
;** Descriptions:         Renewed the template, added codes to support more compilers
;**
;**------------------------------------------------------------------------------------------------------
;** Modified by:         Chenxibing    
;** Modified date:        2004-12-09
;** Version:            1.05
;** Descriptions:
;**
;********************************************************************************************************/

;define the stack size
;定义堆栈的大小
SVC_STACK_LEGTH         EQU         0
FIQ_STACK_LEGTH         EQU         0
IRQ_STACK_LEGTH         EQU         256
ABT_STACK_LEGTH         EQU         0
UND_STACK_LEGTH         EQU         0

NoInt       EQU 0x80
NoFIQ        EQU    0x40

USR32Mode   EQU 0x10
SVC32Mode   EQU 0x13
SYS32Mode   EQU 0x1f
IRQ32Mode   EQU 0x12
FIQ32Mode   EQU 0x11

    IMPORT __use_no_semihosting_swi

;The imported labels
;引入的外部标号在这声明
    IMPORT  FIQ_Exception                   ;Fast interrupt exceptions handler 快速中断异常处理程序
    IMPORT  __main                          ;The entry point to the main function C语言主程序入口
    IMPORT  SysStation                 ;initialize the target board 目标板基本初始化
    
;The emported labels
;给外部使用的标号在这声明
    EXPORT  bottom_of_heap
    EXPORT  StackUsr
    
    EXPORT  Reset
    EXPORT __user_initial_stackheap

    CODE32

    AREA    vectors,CODE,READONLY
        ENTRY

;interrupt vectors
;中断向量表
Reset
        LDR     PC, ResetAddr
        LDR     PC, UndefinedAddr
        LDR     PC, SWI_Addr
        LDR     PC, PrefetchAddr
        LDR     PC, DataAbortAddr
        DCD     0xb9205f80
        LDR     PC, [PC, #-0xff0]
        LDR     PC, FIQ_Addr

ResetAddr           DCD     ResetInit
UndefinedAddr       DCD     Undefined
SWI_Addr            DCD     SoftwareInterrupt
PrefetchAddr        DCD     PrefetchAbort
DataAbortAddr       DCD     DataAbort
Nouse               DCD     0
IRQ_Addr            DCD     0
FIQ_Addr            DCD     FIQ_Handler


;未定义指令
Undefined
        B       Undefined

;软中断
SoftwareInterrupt            
;        B       SoftwareInterrupt
;//增加开/关中断处理 Chenxibing-2004-02-09                                 
        CMP     R0, #4
        LDRLO   PC, [PC, R0, LSL #2]
        MOVS    PC, LR

SwiFunction
        DCD     IRQDisable       ;0
        DCD     IRQEnable        ;1
        DCD        FIQDisable         ;2
        DCD        FIQEnable         ;3

IRQDisable
        ;关IRQ中断
        MRS     R0, SPSR
        ORR     R0, R0, #NoInt
        MSR     SPSR_c, R0
        MOVS    PC, LR

IRQEnable
        ;开IRQ中断
        MRS   R0, SPSR
        BIC   R0, R0, #NoInt
        MSR   SPSR_c, R0
        MOVS    PC, LR
        
FIQDisable
        ;关FIQ中断
        MRS     R0, SPSR
        ORR     R0, R0, #NoFIQ
        MSR     SPSR_c, R0
        MOVS    PC, LR

FIQEnable
        ;开FIQ中断
        MRS   R0, SPSR
        BIC   R0, R0, #NoFIQ
        MSR   SPSR_c, R0
        MOVS    PC, LR
;// Changed 2004-12-09
      
;取指令中止
PrefetchAbort
        B       PrefetchAbort

;取数据中止
DataAbort
        B       DataAbort

;快速中断
FIQ_Handler
        STMFD   SP!, {R0-R3, LR}
        BL      FIQ_Exception
        LDMFD   SP!, {R0-R3, LR}
        SUBS    PC,  LR,  #4

            
;/*********************************************************************************************************
;** unction name     函数名称:     InitStack
;** Descriptions     功能描述:     Initialize the stacks  初始化堆栈
;** input parameters     输 入:       None 无
;** Returned value       输 出 :      None 无
;** Used global variables 全局变量:     None 无
;** Calling modules     调用模块:     None 无
;**
;** Created by         作 者:     Chenmingji 陈明计
;** Created Date     日 期:     2004/02/02 2004年2月2日
;**-------------------------------------------------------------------------------------------------------
;** Modified by     修 改:
;** Modified date     日 期:
;**-------------------------------------------------------------------------------------------------------
;********************************************************************************************************/
InitStack    
        MOV     R0, LR
;Build the SVC stack
;设置管理模式堆栈
        MSR     CPSR_c, #0xd3        
        LDR     SP, StackSvc    
;Build the IRQ stack    
;设置中断模式堆栈
        MSR     CPSR_c, #0xd2
        LDR     SP, StackIrq
;Build the FIQ stack
;设置快速中断模式堆栈
        MSR     CPSR_c, #0xd1
        LDR     SP, StackFiq
;Build the DATAABORT stack
;设置中止模式堆栈
        MSR     CPSR_c, #0xd7
        LDR     SP, StackAbt
;Build the UDF stack
;设置未定义模式堆栈
        MSR     CPSR_c, #0xdb
        LDR     SP, StackUnd
;Build the SYS stack
;设置系统模式堆栈
        MSR     CPSR_c, #0xdf
        LDR     SP, =StackUsr

        MOV     PC, R0

;/*********************************************************************************************************
;** unction name     函数名称:     ResetInit
;** Descriptions     功能描述:     RESET  复位入口
;** input parameters     输 入:       None 无
;** Returned value       输 出 :      None 无
;** Used global variables 全局变量:     None 无
;** Calling modules     调用模块:     None 无
;**
;** Created by         作 者:     Chenmingji 陈明计
;** Created Date     日 期:     2004/02/02 2004年2月2日
;**-------------------------------------------------------------------------------------------------------
;** Modified by     修 改: Chenmingji 陈明计
;** Modified date     日 期: 2004/02/02 2004年3月3日
;**-------------------------------------------------------------------------------------------------------
;********************************************************************************************************/
ResetInit
        
        BL      InitStack               ;初始化堆栈 Initialize the stack
        BL      SysStation         ;目标板基本初始化 Initialize the target board
                                        ;跳转到c语言入口 Jump to the entry point of C program
        B       __main

;/*********************************************************************************************************
;** unction name     函数名称:     __user_initial_stackheap
;** Descriptions     功能描述:     Initial the function library stacks and heaps, CAN not deleted!   库函数初始化堆和栈,不能删除
;** input parameters     输 入:       reference by function library 参考库函数手册
;** Returned value       输 出 :      reference by function library 参考库函数手册
;** Used global variables 全局变量:     None 无
;** Calling modules     调用模块:     None 无
;**
;** Created by         作 者:     Chenmingji 陈明计
;** Created Date     日 期:     2004/02/02 2004年2月2日
;**-------------------------------------------------------------------------------------------------------
;** Modified by     
;** Modified date     
;**-------------------------------------------------------------------------------------------------------
;********************************************************************************************************/
__user_initial_stackheap    
    LDR   r0,=bottom_of_heap
;    LDR   r1,=StackUsr
    MOV   pc,lr


StackSvc           DCD     SvcStackSpace + (SVC_STACK_LEGTH - 1)* 4
StackIrq           DCD     IrqStackSpace + (IRQ_STACK_LEGTH - 1)* 4
StackFiq           DCD     FiqStackSpace + (FIQ_STACK_LEGTH - 1)* 4
StackAbt           DCD     AbtStackSpace + (ABT_STACK_LEGTH - 1)* 4
StackUnd           DCD     UndtStackSpace + (UND_STACK_LEGTH - 1)* 4

;/*********************************************************************************************************
;** unction name     函数名称:     CrpData
;** Descriptions     功能描述:     encrypt the chip
;** input parameters     输 入:       None 无
;** Returned value       输 出 :      None 无
;** Used global variables 全局变量:     None 无
;** Calling modules     调用模块:     None 无
;**
;** Created by         作 者:     Chenmingji 陈明计
;** Created Date     日 期:     2004/03/27 2004年3月27日
;**-------------------------------------------------------------------------------------------------------
;** Modified by     修 改:
;** Modified date     日 期:
;**-------------------------------------------------------------------------------------------------------
;********************************************************************************************************/
    IF :DEF: EN_CRP
        IF  . >= 0x1fc
        INFO    1,"\nThe data at 0x000001fc must be 0x87654321.\nPlease delete some source before this line."
        ENDIF
CrpData
    WHILE . < 0x1fc
    NOP
    WEND
CrpData1
    DCD     0x87654321          ;/*When the Data is 为0x87654321,user code be protected. 当此数为0x87654321时,用户程序被保护 */
    ENDIF
    
;/* 分配堆栈空间 */
        AREA    MyStacks, DATA, NOINIT, ALIGN=2
SvcStackSpace      SPACE   SVC_STACK_LEGTH * 4  ;Stack spaces for Administration Mode 管理模式堆栈空间
IrqStackSpace      SPACE   IRQ_STACK_LEGTH * 4  ;Stack spaces for Interrupt ReQuest Mode 中断模式堆栈空间
FiqStackSpace      SPACE   FIQ_STACK_LEGTH * 4  ;Stack spaces for Fast Interrupt reQuest Mode 快速中断模式堆栈空间
AbtStackSpace      SPACE   ABT_STACK_LEGTH * 4  ;Stack spaces for Suspend Mode 中止义模式堆栈空间
UndtStackSpace     SPACE   UND_STACK_LEGTH * 4  ;Stack spaces for Undefined Mode 未定义模式堆栈


        AREA    Heap, DATA, NOINIT
bottom_of_heap    SPACE   1

        AREA    Stacks, DATA, NOINIT
StackUsr

    END
;/*********************************************************************************************************
;**                            End Of File
;********************************************************************************************************/

我不需要软件中断!


另外我如何修改我的目标板程序?

原文如下:

/****************************************Copyright (c)**************************************************
**                               Guangzou ZLG-MCU Development Co.,LTD.
**                                      graduate school
**                                 http://www.zlgmcu.com
**
**--------------File Info-------------------------------------------------------------------------------
** File name:            target.c
** Last modified Date:    2004-09-17
** Last Version:        1.0
** Descriptions:        header file of the specific codes for LPC2100 target boards
**                        Every project should include a copy of this file, user may modify it as needed
**------------------------------------------------------------------------------------------------------
** Created by:            Chenmingji
** Created date:        2004-02-02
** Version:                1.0
** Descriptions:        The original version
**
**------------------------------------------------------------------------------------------------------
** Modified by:            Chenmingji
** Modified date:        2004-09-17
** Version:                1.01
** Descriptions:        Renewed the template, added more compiler supports
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:    
** Descriptions:
**
********************************************************************************************************/

#define IN_TARGET
#include  "LPC2132.h"
#include "config.h"

/*********************************************************************************************************
** Function name:            IRQ_Exception
**
** Descriptions:            interrupt exceptional handler , change it as needed
**
** input parameters:        None
** Returned value:            None
**         
** Used global variables:    None
** Calling modules:            None
**
** Created by:                Chenmingji
** Created Date:            2004/02/02
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
        void __irq IRQ_Exception(void)
{
    while(1);                   //  change it to your code 这一句替换为自己的代码
}

/*********************************************************************************************************
** Function name:            FIQ_Exception
**
** Descriptions:            Fast interrupt exceptional handler , change it as needed
**
** input parameters:        None
** Returned value:            None
**         
** Used global variables:    None
** Calling modules:            None
**
** Created by:                Chenmingji
** Created Date:            2004/02/02
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
        void FIQ_Exception(void)
{
    while(1);                   // change it to your code  这一句替换为自己的代码
}

/*********************************************************************************************************
** Function name:            TargetInit
**
** Descriptions:            Initialize the target board; it is called in a necessary place, change it as
**                            needed
**
** input parameters:        None
** Returned value:            None
**         
** Used global variables:    None
** Calling modules:            None
**
** Created by:                Chenmingji
** Created Date:            2004/02/02
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
       void TargetInit(void)
{
    /* 添加自己的代码 */
    /* Add your codes here */
}

/*********************************************************************************************************
** Function name:            TargetResetInit
**
** Descriptions:            Initialize the target board before running the main() function; User may
**                            change it as needed, but may not deleted it.
**
** input parameters:        None
** Returned value:            None
**         
** Used global variables:    None
** Calling modules:            None
**
** Created by:                Chenmingji
** Created Date:            2004/02/02
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
        void TargetResetInit(void)
{
#ifdef __DEBUG_RAM    
    MEMMAP = 0x2;                   //remap
#endif

#ifdef __DEBUG_FLASH    
    MEMMAP = 0x1;                   //remap
#endif

#ifdef __IN_CHIP    
    MEMMAP = 0x1;                   //remap
#endif

/* 设置系统各部分时钟 */
/* Set system timers for each component */
    PLLCON = 1;
#if (Fpclk / (Fcclk / 4)) == 1
    VPBDIV = 0;
#endif
#if (Fpclk / (Fcclk / 4)) == 2
    VPBDIV = 2;
#endif
#if (Fpclk / (Fcclk / 4)) == 4
    VPBDIV = 1;
#endif

#if (Fcco / Fcclk) == 2
    PLLCFG = ((Fcclk / Fosc) - 1) | (0 << 5);
#endif
#if (Fcco / Fcclk) == 4
    PLLCFG = ((Fcclk / Fosc) - 1) | (1 << 5);
#endif
#if (Fcco / Fcclk) == 8
    PLLCFG = ((Fcclk / Fosc) - 1) | (2 << 5);
#endif
#if (Fcco / Fcclk) == 16
    PLLCFG = ((Fcclk / Fosc) - 1) | (3 << 5);
#endif
    PLLFEED = 0xaa;
    PLLFEED = 0x55;
    while((PLLSTAT & (1 << 10)) == 0);
    PLLCON = 3;
    PLLFEED = 0xaa;
    PLLFEED = 0x55;
    
    /* 设置存储器加速模块 */
    /* Set memory accelerater module*/
    MAMCR = 0;
#if Fcclk < 20000000
    MAMTIM = 1;
#else
#if Fcclk < 40000000
    MAMTIM = 2;
#else
    MAMTIM = 3;
#endif
#endif
    MAMCR = 2;
    
    /* 初始化VIC */
    /* initialize VIC*/
    VICIntEnClr = 0xffffffff;
    VICVectAddr = 0;
    VICIntSelect = 0;

    /* 添加自己的代码 */
    /* Add your codes here */

}

/*********************************************************************************************************
**                  以下为一些与系统相关的库函数的实现
**                  具体作用请ads的参考编译器与库函数手册
**                  用户可以根据自己的要求修改        
********************************************************************************************************/
/*********************************************************************************************************
**                  The implementations for some library functions
**                  For more details, please refer to the ADS compiler handbook and The library
**                    function manual
**                  User could change it as needed       
********************************************************************************************************/
//#include "rt_sys.h"
//#include "stdio.h"

/* Chxb */
#include <rt_sys.h>
#include <stdio.h>
#pragma import(__use_no_semihosting_swi)

        int __rt_div0(int a)
{
    a = a;
    return 0;
}

        int fputc(int ch,FILE *f)
{
    ch = ch;
    f = f;
    return 0;
}

    int fgetc(FILE *f)
{
    f = f;
    return 0;
}


        int _sys_close(FILEHANDLE fh)
{
    fh = fh;
    return 0;
}

        int _sys_write(FILEHANDLE fh, const unsigned char * buf,
                      unsigned len, int mode)
{
    fh = fh;
    buf = buf;
    len =len;
    mode = mode;
    return 0;
}
        int _sys_read(FILEHANDLE fh, unsigned char * buf,
                     unsigned len, int mode)
{
    fh = fh;
    buf = buf;
    len =len;
    mode = mode;
    
    return 0;
}

       void _ttywrch(int ch)
{
    ch = ch;
}

        int _sys_istty(FILEHANDLE fh)
{
    fh = fh;
    return 0;
}
        int _sys_seek(FILEHANDLE fh, long pos)
{
    fh = fh;
    return 0;
}
        int _sys_ensure(FILEHANDLE fh)
{
    fh = fh;
    return 0;
}

        long _sys_flen(FILEHANDLE fh)
{
    fh = fh;
    return 0;
}
       int _sys_tmpnam(char * name, int sig, unsigned maxlen)
{
    name = name;
    sig = sig;
    maxlen = maxlen;
    return 0;
}

        void _sys_exit(int returncode)
{
    returncode = returncode;
}

        char *_sys_command_string(char * cmd, int len)
{
    cmd = cmd;
    len = len;
    return 0;
}


/*********************************************************************************************************
**                            End Of File
********************************************************************************************************/


如果我只作一般的MCU来运行怎么修改?

请大家不要见笑,小弟刚学!还希望得到大家的支持! 1: 最好直接用Keil,拿来就做MCU 2: 感谢 hotpower你的程序我运行不了!

不知道为什么?

能否告诉我如何设置啊?

3: 用周立公的启动一样可以阿 里面有用做MCU,用多UC/OS。。。模板阿。
如果你觉得不会改,对照那里改。 4: 哈哈,现在感觉ARMMCU一样好用,甚至更好~~~没必要照别人的思路去学~~~瞎想才是硬道理~~~ 5: 如果用ADS,ZLG书有例程。直接用摸班,不用修改。还是买本书,买个班子吧。很快就上手了。 6: 同意hotpower老师的"瞎想"我们真的需要点瞎想精神啊!!!~~~

今天去支持一个客户,当给出解决方案是,他问了我一个问题,让我久久不能平静:我们完全按照芯片手册上的参考电路做的,怎么会错?

... 7: terrence被吓倒了把很多人都喜欢来这个“完全”。。。 8: 硬件可以完全软件呢? 9: re要是只用作一般mcu
keil 环境下觉得好用一些,带上其startup文件就可以了.. 10: 好用才是硬道理!

共2条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]