Re: PIC12F510 problem
|
||||
---|---|---|---|---|
高級會員
|
不知道是啥原因
在我發文過後,重新BUILD 再去執行程式 完全沒加 NOP 一切正常 READ_MODIFY_WRITE 沒有確定的結果嗎?
發表於: 2006/6/12 18:01
|
|||
微電腦自動控制設計,產品製造
才疏學淺,若有錯誤敬請指正 |
||||
|
Re: PIC12F510 problem
|
||||
---|---|---|---|---|
高級會員
|
請問板大,這種情形應該不會發生在18F對吧
我有一個簡單的CODE LED死都不亮(LOW 推動) 能幫我看一下嗎
list p=18f458
板子是自己焊的 LED用線短路到地測試過了會亮(CPU拔起來,從IO的位置短路) 用ICD2跑 WATCH PORTB 執行BCF的時候,他的值都不會改變 不知道是啥問題 剛開始用18F,還不是很清楚他的IO跟以前16C有何差異 怎會這樣
發表於: 2006/6/9 18:06
|
|||
微電腦自動控制設計,產品製造
才疏學淺,若有錯誤敬請指正 |
||||
|
Re: PIC12F510 problem
|
||||
---|---|---|---|---|
版主
|
這種現象稱之為 " READ-MODIFY-WRITE ",在 Data Sheet 裡有詳細的說明。在對同一PORT的BIT連續動作時需插入一個NOP指令以避免發生READ-MODIFY-WRITE 的動作。
5.5.2 SUCCESSIVE OPERATIONS ON I/O PORTS The actual write to an I/O port happens at the end of an instruction cycle. Whereas for reading, the data must be valid at the beginning of the instruction cycle (Figure 5-14). Therefore, care must be exercised if a write followed by a read operation is carried out on the same I/O port. The sequence of instructions should allow the pin voltage to stabilize (load dependent) before the next instruction causes the file to be read into the CPU. Otherwise, the previous state of that pin may be read into the CPU rather than the new state. When in doubt, it is better to separate these instructions with a NOP or another instruction not accessing this I/O port.
發表於: 2006/6/9 9:33
|
|||
|
Re: PIC12F510 problem
|
||||
---|---|---|---|---|
高級會員
|
他們有個名詞在解釋連續對IO寫入讀出錯誤的情形
我忘了叫啥 基本上是這樣 當你BSF指令執行的時候,他會先讀入再輸出,連續執行時 因為時序的關係這樣會有錯誤 解決的方法是在 TRIS之後加一條NOP 每個BSF之間加一條NOP
發表於: 2006/6/8 19:20
|
|||
微電腦自動控制設計,產品製造
才疏學淺,若有錯誤敬請指正 |
||||
|
PIC12F510 problem
|
||||
---|---|---|---|---|
新會員
|
怎样把GP0,GP1,GP2定义成GPIO ?
#include <P12F510.INC> __CONFIG _CP_OFF & _MCLRE_OFF & _IOSCFS_OFF & _WDT_OFF & _IntRC_OSC ORG 0x000 ; coding begins here clrf CM1CON0 clrf ADCON0 movlw b'001000' tris GPIO ; Initialize output port bsf GPIO, 0 bsf GPIO, 1 bsf GPIO, 2 bsf GPIO, 4 bsf GPIO, 5 END 这样简单的代码,怎么GPIO拿不到1呢? 请高手赐教。多谢!
發表於: 2006/6/7 18:43
|
|||
|