搜索
bottom↓
回复: 7

装了SDCC,CodeBlocks,新建一个小工程,编译无问题,运行却不正确

[复制链接]

出0入0汤圆

发表于 2010-12-21 13:58:25 | 显示全部楼层 |阅读模式
源码在下面,就是让两个LED闪烁。

附件中包括了源码,工程文件以及各Proteus模型。   点击此处下载 ourdev_606101LQ7SM4.rar(文件大小:19K) (原文件名:sbittst.rar)


另外顺便问一下,网上老邓的CodeBlocks便携版,Cscope怎么用?



// main.h

#ifndef _MAIN_H_
        #define _MAIN_H_
        #include <at89x52.h>

        typedef unsigned char         uint_8;
        typedef signed char         int_8;
        typedef unsigned int         uint_16;
        typedef signed int         int_16;
        typedef unsigned long         uint_32;
        typedef signed long         int_32;

        __sbit __at 0x90 LED01;
        __sbit __at 0x97 LEDFlash;

        void timer0_init(void);
        void timer0_update(void);

#endif

---------------------------------------------------------------

// main.c


/*
Project:
Compiler:MCS-51 MCU SDCC Compiler
*/

#include "main.h"

void main(void)
{
    LED01 = 0;
    LEDFlash = 1;

    timer0_update();

    while(1)
    {
        if(TF0)
        {
            LED01 ^= 1;
            LEDFlash ^= 1;

            timer0_update();
        }


    }
}

void timer0_init(void)
{
    TMOD &= 0xF0;
    TMOD |= 0x01;
    TF0  = 1;
    TR0  = 1;
}

void timer0_update(void)
{
    TF0  = 0;
    TL0  = 0x00;
    TH0  = 0xC0;
}

阿莫论坛20周年了!感谢大家的支持与爱护!!

知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)

出0入0汤圆

发表于 2010-12-21 15:10:17 | 显示全部楼层
开源的SDCC没用过,知道的来指点下

出0入0汤圆

 楼主| 发表于 2010-12-21 16:50:55 | 显示全部楼层
从Proteus运行状况来看,TMOD没有赋值,运行中TH、TL不变化

出0入0汤圆

发表于 2010-12-21 19:13:54 | 显示全部楼层
void main(void)
{
    LED01 = 0;
    LEDFlash = 1;

timer0_update(); //这个要改成timer0_init() 吧?


    while(1)

出0入0汤圆

 楼主| 发表于 2010-12-21 20:33:49 | 显示全部楼层
谢谢Shark

搞定

出0入0汤圆

 楼主| 发表于 2010-12-21 20:36:13 | 显示全部楼层
继续请教

网上老邓的CodeBlocks便携版,Cscope怎么用? 怎么用都没什么反应哦

我希望像Source Insight类似,选中一个标识符,可以看见定义什么的。

出0入0汤圆

发表于 2014-10-10 14:21:38 | 显示全部楼层
zieous 发表于 2010-12-21 20:36
继续请教

网上老邓的CodeBlocks便携版,Cscope怎么用? 怎么用都没什么反应哦

请教楼主,CodeBlocks中使用SDCC编译楼主的代码,无法生成目标文件 ihx。编译结果如下:没有错误和警告,最后两行是红色的是怎么回事?

-------------- Build: Release in test (compiler: Small Device C Compiler)---------------

sdcc.exe -L"C:\Program Files\SDCC2.9.0\lib" -o bin\Release\test.ihx -mmcs51 --model-medium  --opt-code-size  --out-fmt-ihx --no-pack-iram --xstack   --xram-size 4096 --iram-size 256 --code-size 65536 --out-fmt-ihx   obj\Release\main.o
at 1: warning 119: don't know what to do with file 'obj\Release\main.o'. file extension unsupported
SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.9.0 #5416 (Mar 22 2009) (MINGW32)
Usage : sdcc [options] filename
Options :-
General options:
      --help                Display this help
  -v  --version             Display sdcc's version
      --verbose             Trace calls to the preprocessor, assembler, and linker
  -V                        Execute verbosely.  Show sub commands as they are run
  -d                        
  -D                        Define macro as in -Dmacro
  -I                        Add to the include (*.h) path, as in -Ipath
  -A                        
  -U                        
  -M                        Preprocessor option
  -W                        Pass through options to the pre-processor (p), assembler (a) or linker (l)
  -S                        Compile only; do not assemble or link
  -c  --compile-only        Compile and assemble, but do not link
  -E  --preprocessonly      Preprocess only, do not compile
      --c1mode              Act in c1 mode.  The standard input is preprocessed code, the output is assembly code.
  -o                        Place the output into the given path resp. file
      --print-search-dirs   display the directories in the compiler's search path
      --vc                  messages are compatible with Micro$oft visual studio
      --use-stdout          send errors to stdout instead of stderr
      --nostdlib            Do not include the standard library directory in the search path
      --nostdinc            Do not include the standard include directory in the search path
      --less-pedantic       Disable some of the more pedantic warnings
      --disable-warning     <nnnn> Disable specific warning
      --Werror              Treat the warnings as errors
      --debug               Enable debugging symbol output
      --cyclomatic          Display complexity of compiled functions
      --std-c89             Use C89 standard only
      --std-sdcc89          Use C89 standard with SDCC extensions (default)
      --std-c99             Use C99 standard only (incomplete)
      --std-sdcc99          Use C99 standard with SDCC extensions (incomplete)
      --fdollars-in-identifiers  Permit '$' as an identifier character
      --funsigned-char      Make "char" unsigned by default
Code generation options:
  -m                        Set the port to use e.g. -mz80.
  -p                        Select port specific processor e.g. -mpic14 -p16f84
      --model-large         external data space is used
      --model-medium        external paged data space is used
      --model-small         internal data space is used (default)
      --stack-auto          Stack automatic variables
      --xstack              Use external stack
      --int-long-reent      Use reentrant calls on the int and long support functions
      --float-reent         Use reentrant calls on the float support functions
      --main-return         Issue a return after main()
      --xram-movc           Use movc instead of movx to read xram (xdata)
      --callee-saves        <func[,func,...]> Cause the called function to save registers insted of the caller
      --profile             On supported ports, generate extra profiling information
      --fommit-frame-pointer  Leave out the frame pointer.
      --all-callee-saves    callee will always save registers used
      --stack-probe         insert call to function __stack_probe at each function prologue
      --no-xinit-opt        don't memcpy initialized xram from code
      --no-c-code-in-asm    don't include c-code as comments in the asm file
      --no-peep-comments    don't include peephole optimizer comments
      --fverbose-asm        include code generator comments
      --short-is-8bits      Make short 8 bits (for old times sake)
      --codeseg             <name> use this name for the code segment
      --constseg            <name> use this name for the const segment
Optimization options:
      --nooverlay           Disable overlaying leaf function auto variables
      --nogcse              Disable the GCSE optimisation
      --nolabelopt          Disable label optimisation
      --noinvariant         Disable optimisation of invariants
      --noinduction         Disable loop variable induction
      --nojtbound           Don't generate boundary check for jump tables
      --noloopreverse       Disable the loop reverse optimisation
      --no-peep             Disable the peephole assembly file optimisation
      --no-reg-params       On some ports, disable passing some parameters in registers
      --peep-asm            Enable peephole optimization on inline assembly
      --peep-file           <file> use this extra peephole file
      --opt-code-speed      Optimize for code speed rather than size
      --opt-code-size       Optimize for code size rather than speed
Internal debugging options:
      --dumpraw             Dump the internal structure after the initial parse
      --dumpgcse            
      --dumploop            
      --dumpdeadcode        
      --dumpliverange      
      --dumpregpack         
      --dumpregassign      
      --dumptree            dump front-end AST before generating iCode
      --dumpall             Dump the internal structure at all stages
      --i-code-in-asm       include i-code as comments in the asm file
Linker options:
  -l                        Include the given library in the link
  -L                        Add the next field to the library search path
      --lib-path            <path> use this path to search for libraries
      --out-fmt-ihx         Output in Intel hex format
      --out-fmt-s19         Output in S19 hex format
      --xram-loc            <nnnn> External Ram start location
      --xram-size           <nnnn> External Ram size
      --iram-size           <nnnn> Internal Ram size
      --xstack-loc          <nnnn> External Stack start location
      --code-loc            <nnnn> Code Segment Location
      --code-size           <nnnn> Code Segment size
      --stack-loc           <nnnn> Stack pointer initial value
      --data-loc            <nnnn> Direct data start location
      --idata-loc           
Special options for the mcs51 port:
      --stack-size          Tells the linker to allocate this space for stack
      --parms-in-bank1      use Bank1 for parameter passing
      --pack-iram           Tells the linker to pack variables in internal ram (default)
      --no-pack-iram        Tells the linker not to pack variables in internal ram
      --acall-ajmp          Use acall/ajmp instead of lcall/ljmp
Special options for the gbz80 port:
      -bo                   <num> use code bank <num>
      -ba                   <num> use data bank <num>
      --callee-saves-bc     Force a called function to always save BC
      --codeseg             <name> use this name for the code segment
      --constseg            <name> use this name for the const segment
      --no-std-crt0         For the z80/gbz80 do not link default crt0.o
Special options for the z80 port:
      --callee-saves-bc     Force a called function to always save BC
      --portmode=           Determine PORT I/O mode (z80/z180)
      --asm=                Define assembler name (rgbds/asxxxx/isas/z80asm)
      --codeseg             <name> use this name for the code segment
      --constseg            <name> use this name for the const segment
      --no-std-crt0         For the z80/gbz80 do not link default crt0.o
Special options for the ds390 port:
      --model-flat24        use the flat24 model for the ds390 (default)
      --stack-8bit          use the 8bit stack for the ds390 (not supported yet)
      --stack-size          Tells the linker to allocate this space for stack
      --pack-iram           Tells the linker to pack variables in internal ram (default)
      --no-pack-iram        Tells the linker not to pack variables in internal ram
      --stack-10bit         use the 10bit stack for ds390 (default)
      --use-accelerator     generate code for ds390 arithmetic accelerator
      --protect-sp-update   will disable interrupts during ESP:SP updates
      --parms-in-bank1      use Bank1 for parameter passing
Special options for the pic16 port:
      --pstack-model=       use stack model 'small' (default) or 'large'
  -y  --extended            enable Extended Instruction Set/Literal Offset Addressing mode
      --pno-banksel         do not generate BANKSEL assembler directives
      --obanksel=           set banksel optimization level (default=0 no)
      --denable-peeps       explicit enable of peepholes
      --no-optimize-goto    do NOT use (conditional) BRA instead of GOTO
      --optimize-cmp        try to optimize some compares
      --optimize-df         thoroughly analyze data flow (memory and time intensive!)
      --asm=                Use alternative assembler
      --mplab-comp          enable compatibility mode for MPLAB utilities (MPASM/MPLINK)
      --link=               Use alternative linker
      --preplace-udata-with=  Place udata variables at another section: udata_acs, udata_ovr, udata_shr
      --ivt-loc=            Set address of interrupt vector table.
      --nodefaultlibs       do not link default libraries when linking
      --use-crt=            use <crt-o> run-time initialization module
      --no-crt              do not link any default run-time initialization module
      --debug-xtra          show more debug info in assembly output
      --debug-ralloc        dump register allocator debug file *.d
      --pcode-verbose       dump pcode related info
      --calltree            dump call tree in .calltree file
      --gstack              trace stack pointer push/pop to overflow
Special options for the pic14 port:
      --debug-xtra          show more debug info in assembly output
      --no-pcode-opt        disable (slightly faulty) optimization on pCode
      --stack-size          sets the size if the argument passing stack (default: 16, minimum: 4)
Special options for the TININative port:
      --model-flat24        use the flat24 model for the ds390 (default)
      --stack-8bit          use the 8bit stack for the ds390 (not supported yet)
      --stack-size          Tells the linker to allocate this space for stack
      --pack-iram           Tells the linker to pack variables in internal ram (default)
      --no-pack-iram        Tells the linker not to pack variables in internal ram
      --stack-10bit         use the 10bit stack for ds390 (default)
      --use-accelerator     generate code for ds390 arithmetic accelerator
      --protect-sp-update   will disable interrupts during ESP:SP updates
      --parms-in-bank1      use Bank1 for parameter passing
      --tini-libid          <nnnn> LibraryID used in -mTININative
Special options for the ds400 port:
      --model-flat24        use the flat24 model for the ds400 (default)
      --stack-8bit          use the 8bit stack for the ds400 (not supported yet)
      --stack-size          Tells the linker to allocate this space for stack
      --pack-iram           Tells the linker to pack variables in internal ram (default)
      --no-pack-iram        Tells the linker not to pack variables in internal ram
      --stack-10bit         use the 10bit stack for ds400 (default)
      --use-accelerator     generate code for ds400 arithmetic accelerator
      --protect-sp-update   will disable interrupts during ESP:SP updates
      --parms-in-bank1      use Bank1 for parameter passing
Special options for the hc08 port:
      --out-fmt-elf         Output executable in ELF format
Process terminated with status 1 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))

出0入0汤圆

发表于 2014-12-16 14:16:03 | 显示全部楼层
不知道楼主是如何配置的,codeblocks和SDCC
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片。注意:要连续压缩2次才能满足要求!!】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-7-23 10:30

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

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