搜索
bottom↓
回复: 2

求教各位大侠 PIC12F怎么不工作?

[复制链接]

出0入0汤圆

发表于 2008-5-31 12:46:52 | 显示全部楼层 |阅读模式
大家好,我刚接了一个任务用PIC12F675 开发个电压测量,高点亮绿灯,低点亮红灯.一开始感觉很简单,我也看了和抄了网上的一些程序,我的设计思路是这样,我先能让单片机工作能点亮一个灯,以后就好办.但 就是点不亮.
  程序: p=12f675
        #include<12f675.inc>
        org 0x00
       main
        nop
       bsf status,rp0;
       movlw 0x00;
       movwf OPTION_REG;
       clrf GPIO;
      movlw 0x07;
     movwf CMCON;
     bsf status,rp0;
     clrf ansel;
     bsf  status,rp0;
     movlw 0x0b;
     TRIS  GPIO;
    clrwdt;
    bsf gpio,4;
    bsf gpio,5;
qwe  
    nop
    bsf  gpio,4;
    bsf gpio,5;
   clrwdt;
   goto quw;
   end;

   我用的是MPLAB 8.0,编译通过了,有几个WARING,提示不在BANK0内.烧录器用的是周立功的EASYPRO 280U.
选用内部震荡,I/O.我现在不知道问题出在那里,是程序,还是设置,还是烧录器.
  我的交货是6月6号,希望大家多指教,不胜感激.我电话是13501720418 刘.
                         

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

月入3000的是反美的。收入3万是亲美的。收入30万是移民美国的。收入300万是取得绿卡后回国,教唆那些3000来反美的!

出0入0汤圆

发表于 2008-6-1 09:38:57 | 显示全部楼层
估计是格式:
;**********************************************************************
;   This file is a basic code template for assembly code generation   *
;   on the PIC12F675. This file contains the basic code               *
;   building blocks to build upon.                                    *
;                                                                     *
;   Refer to the MPASM User's Guide for additional information on     *
;   features of the assembler (Document DS33014).                     *
;                                                                     *
;   Refer to the respective PIC data sheet for additional             *
;   information on the instruction set.                               *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Filename:            xxx.asm                                           *
;    Date:                                                            *
;    File Version:                                                    *
;                                                                     *
;    Author:                                                          *
;    Company:                                                         *
;                                                                     *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Files Required: P12F675.INC                                      *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Notes:                                                           *
;                                                                     *
;**********************************************************************

        list      p=12f675           ; list directive to define processor
        #include <p12f675.inc>        ; processor specific variable definitions

        errorlevel  -302              ; suppress message 302 from list file

        __CONFIG   _CP_OFF & _CPD_OFF & _BODEN_OFF & _MCLRE_ON & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT

; '__CONFIG' directive is used to embed configuration word within .asm file.
; The lables following the directive are located in the respective .inc file.
; See data sheet for additional information on configuration word settings.




;***** VARIABLE DEFINITIONS
w_temp        EQU     0x20        ; variable used for context saving
status_temp   EQU     0x21        ; variable used for context saving






;**********************************************************************
                ORG     0x000             ; processor reset vector
                goto    main              ; go to beginning of program
       

                ORG     0x004             ; interrupt vector location
                movwf   w_temp            ; save off current W register contents
                movf        STATUS,w          ; move status register into W register
                movwf        status_temp       ; save off contents of STATUS register


; isr code can go here or be located as a call subroutine elsewhere


                movf    status_temp,w     ; retrieve copy of STATUS register
                movwf        STATUS            ; restore pre-isr STATUS register contents
                swapf   w_temp,f
                swapf   w_temp,w          ; restore pre-isr W register contents
                retfie                    ; return from interrupt


; these first 4 instructions are not required if the internal oscillator is not used
main
                call    0x3FF             ; retrieve factory calibration value
                bsf     STATUS,RP0        ; set file register bank to 1
                movwf   OSCCAL            ; update register with factory cal value
                bcf     STATUS,RP0        ; set file register bank to 0


; remaining code goes here



; initialize eeprom locations

                ORG        0x2100
                DE        0x00, 0x01, 0x02, 0x03


                END                       ; directive 'end of program'

出0入0汤圆

发表于 2008-6-2 11:34:53 | 显示全部楼层
1.端口默认是模拟口,要把驱动灯的口设置为数字口。
2.或许等亮了,但是你看不出来。
3.相关寄存器配置错误。

用示波器看看,活用软件模拟运行一下看看。

这个东西就用12f675啊?真的有点奢侈啊。
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-4-27 20:49

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

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