• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
:::


Browsing this Thread:   1 Anonymous Users






Re: 求助 12f675晶片簡單範例
#7
版主
版主


查看用戶資訊
還有要將ADC關掉,請加上 CLRF ANSEL 指令,ANSEL Reg in the bank 1:

movlw b'00100000' ; Sep GPIO<4:0> for output
movwf TRISIO
clrf ANSEL

發表於: 2005/10/7 15:39
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 求助 12f675晶片簡單範例
#6
初級會員
初級會員


查看用戶資訊
嗚~~~試不出來><""
我有CPOY上面的程式測試
也將movwf TRIAIO此行錯誤改為movwf TRISIO
並於MAIN之後新增3行
bsf CMCON,0
bsf CMCON,1
bsf CMCON,2
關閉比較器功能
可是之後~~我使用MPLAB SIM模擬與使用Watch觀看暫存器
可是得到的答案是
GPIO ===>00000000 <===不是應該00000010
TRISIO==>00000000 <===不是應該00100000嗎?
CMCON==>00000111 <===這個沒問題

知道的幫我一下


程式碼
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_OFF _WDT_OFF _PWRTE_ON &_EXTRC_OSC_NOCLKOUT 
please see the p12f675.inc for the configuration defination
;***** 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
;
bsf    CMCON,0
bsf CMCON
,1
bsf CMCON
,2        
banksel TRISIO        
Set to Bank 1


    
movlw     
b'00100000'    Sep GPIO<4:0> for output        
movwf    TRISIO
;        
banksel    GPIO        to Bank 0    
    
bcf    GPIO
,0        Clear GP0        
nop            
Wait 1 cyclr for read-modify-write issue        
bsf    GPIO
,1        Set GP1

;        
;        
;
initialize eeprom locations        
ORG    0x2100        
DE    0x00
0x010x020x03        
END                       
directive 'end of program'



發表於: 2005/10/6 14:58
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 求助 12f675晶片簡單範例
#5
初級會員
初級會員


查看用戶資訊
謝謝版主 與 Summer
我還沒試驗~~
謝謝你們囉

我若試驗有問題再來~~^^
沒問題~~就只有感溫感溫~~^^

發表於: 2005/10/5 10:41
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 求助 12f675晶片簡單範例
#4
版主
版主


查看用戶資訊
Summer,

謝謝提醒,我忘了比較器的存在。

CMCON暫存器的 CM<2:0> 開機後的內定值為 000 , 此時 GP0 and GP1 被設為比較器輸入,所以要將其設為 111

發表於: 2005/10/3 17:34
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 求助 12f675晶片簡單範例
#3
初級會員
初級會員


查看用戶資訊
sakanayy
請注意CMCON那個暫存器的設定喔!! 很多人吃過悶虧...

發表於: 2005/9/30 20:41
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 求助 12f675晶片簡單範例
#2
版主
版主


查看用戶資訊
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_OFF _WDT_OFF _PWRTE_ON _EXTRC_OSC_NOCLKOUT 
please see the p12f675.inc for the configuration defination

;***** 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
;
        
banksel TRISIO        Set to Bank 1
        movlw     
b'00100000'    Sep GPIO<4:0> for output
        movwf    TRIAIO
;
        
banksel    GPIO        to Bank 0
        bcf    GPIO
,0        Clear GP0
        nop            
Wait 1 cyclr for read-modify-write issue
        bsf    GPIO
,1        Set GP1
        
;
        ;
        ;

initialize eeprom locations

        ORG    0x2100
        DE    0x00
0x010x020x03


        END                       
directive 'end of program'


發表於: 2005/9/30 13:34
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


求助 12f675晶片簡單範例
#1
初級會員
初級會員


查看用戶資訊
@@!!我試幾次寫簡單的程式讓該晶片run
可是無法動作= =''

之前有寫過18f452的跟16f88

這次要寫12f675我不是很清楚該晶片要動作時要設定哪些暫存器

能否請熟悉的人幫我寫一下簡單的範例

那容就是
將GP0跟GP1設定成0跟1
CLICK由GP5進入

另外一個問題
我GP5已經接輸入的CLICK 那是否代表我無法在將GP5規劃為輸出腳使用呢


感謝大家~~~Orz


發表於: 2005/9/30 12:20
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------