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


Browsing this Thread:   1 Anonymous Users






GPIO<5:4>無法設成'OUTPUT'
#1
新會員
新會員


查看用戶資訊
片段

***************

list p=12f629
include "c:\program files\mplab ide\mchip_tools\p12f629.inc"

__CONFIG _CP_ON&_WDT_OFF&_MCLRE_OFF&_INTRC_OSC_NOCLKOUT&_PWRTE_ON&_BODEN_ON


;***** VARIABLE DEFINITIONS *****
CBLOCK 0x20

clkcount

W_TEMP ;
STATUS_TEMP ;



endc

;


;************************

ORG 0x000 ; coding begins here

bsf STATUS,RP0
call 3FFh
movwf OSCCAL

goto _MAIN

;****************************
;Interrupt Vector
interpt:
ORG 0x04
movwf W_TEMP ;
;
swapf STATUS,W ;
bcf STATUS,RP0 ;
;
movwf STATUS_TEMP ;


NOP

SER_EXIT:
bcf STATUS,RP0 ;
swapf STATUS_TEMP,W ;
;
movwf STATUS ;
swapf W_TEMP,F ;
swapf W_TEMP,W ;
retfie
;****************************
_MAIN:
call init
_doing:
nop

goto _doing

;**************************
init: ;在PAGE0
bcf STATUS,RP0 ;Bank 0
clrf GPIO ;Init GPIO
movlw 07h ;Set GP<2:0> to
movwf CMCON ;digital IO(Not ADC IN)

bcf T1CON,T1OSCEN
bcf T1CON,TMR1GE

bsf STATUS,RP0 ;Bank 1
movlw b'11110000' ;wake pull-ups
movwf WPU

;clrf ANSEL ;digital I/O
movlw b'11001111'
movwf TRISIO

movlw b'10000000' ;
movwf OPTION_REG

movlw b'00001111'
movwf IOCB ;pin on change

bcf STATUS,RP0
NOP

bsf INTCON,PEIE
bsf INTCON,T0IE
bsf INTCON,GIE
return

END



發表於: 2004/6/13 18:29
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: GPIO<5:4>無法設成'OUTPUT'
#2
版主
版主


查看用戶資訊
我把您的程式,叫進去MPLAB組譯,並且跑了一下,發現,TRISIO的BIT5和BIT4會被設為0,也就是已經是OUTPUT模式了。
並且,我用以下的程式片斷,來測試,發現GPIO 4, GPIO 5也都可以送出0和1資料。

_doing:
BSF GPIO,4
NOP
BCF GPIO,5
NOP
BCF GPIO,4
NOP
BSF GPIO,5
nop
goto _doing

您是不是碰到了所謂"Read-Modify-Write"的問題?詳情請參考右方「江湖一點訣」。

發表於: 2004/6/18 15:00
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... ]

教育訓練中心

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