Re: 奇怪,,,奇怪......好奇怪??
|
||||
---|---|---|---|---|
版主
|
恭喜您!可以去泡妞了。
CMCON是用來設定比較器的模式用的。如果相關的腳是當作一般的I/O來用,就要把比較器的功能關掉,I/O動作才會正常。 不過,建議程式在開始之後,還是加一段DELAY的程式,再進行耗電的動作會比較安全。 看一下10F2XX的DATA SHEET,應該是有些內含比較器,有些沒有。
發表於: 2005/6/18 11:48
|
|||
|
Re: 奇怪,,,奇怪......好奇怪??
|
||||
---|---|---|---|---|
版主
|
也許在main1的前一行,加上
call pause_250ms 您的問題就解決了。 我的理論是:原來的程式,在送電後,電源還不沒到很穩定的定位時,,它就開始點LED。於是,耗電造成瞬間壓降;PIC想要重置,電壓卻又降得不夠低,重置不良,就當了。 加一些delay,等電壓穩了,再點LED,就沒事了。
發表於: 2005/6/17 12:04
|
|||
|
奇怪,,,奇怪......好奇怪??
|
||||
---|---|---|---|---|
資深會員
|
笨笨鴨, 又碰到問題囉,,
以下是現成的程式, 我用BFMP燒錄器,mcu 用10F206 燒錄結果ok 但是用萬用板實際測試,mcu卻不會工作 又換了一個10F206 結果還是一樣 失望之餘 又換了一個10F202燒錄 奇怪...居然會工作了, 這麼個程式應該是給10F206用的 結果是..... 奇怪,,,奇怪 .....好奇怪?? 10F202, 10F206, BFMP 都是新買的 不知 笨笨鴨 這次又做了甚麼糗事..... ; File Name:PIC10F206_06.asm, by John Massa, Nov 26, 2004, Ver 1.00 ; Description: Three LEDs blink in sequence (Chase). ;-----[Schematic]------------------------------------------------------------ ; PIC10F206 ; _ _ ; GP0, ICSPDAT, Cin+ [ \_/ ] GP3, MCLR/, Vpp ; Vss, Ground [ ] Vdd, +2.0 VDC to +5.5 VDC ; GP1, ICSPCLK, Cin- [_____] GP2, T0CKI, Cout, FOSC4 ;-----[Configuration]-------------------------------------------------------- LIST ; P10F206.INC Standard Header File, Version 1.01 Microchip Technology, Inc. NOLIST #include <p10F206.inc> ; processor specific variables ; Configure: Controls the reset pin, code protect, oscillator selection, WDT. __CONFIG _MCLRE_OFF & _CP_OFF & _WDT_OFF ;-----[Defines & Variable Assignments]--------------------------------------- cblock 0x08 COUNT ; Count buffer COUNT1 ; Count1 buffer endc ;-----[Reset Vector]--------------------------------------------------------- ORG 0x000 ; PIC goes here (Origin of code) after reset. movwf OSCCAL ; Load the oscillator calibration factor. goto init ; go to initialization routine ;-----[Interrupt Vector]----------------------------------------------------- ; Note: PIC10F202/206 does not use interrupts. ;-----[Initialization]------------------------------------------------------- init ;-----[OPTION]--------------------------------------------------------------- ; OPTION register controls wake on GP0,1,3 change, GP0,1,3 pull-ups, TM0, etc movlw b'10000111' ; Set pull-ups only, max pre-scaler OPTION ; ;-----[CMCON0]--------------------------------------------------------------- ; Comparator control register movlw b'10001111' ; Turn-off the comparator, enable the I/O pins. movwf CMCON0 ;-----[TRIS]----------------------------------------------------------------- ; TRIS (reg#) tri-state I/O register. All I/O pins default to inputs at reset. movlw b'00001000' ; Set GPIO pin 3 to an input, pins 0 - 3 to outputs. TRIS GPIO ; Register 06h ;-----[Main routine]--------------------------------------------------------- main ; Three LEDs will sequence (Chase). bcf GPIO,0 ; Turn-off all the LEDs bcf GPIO,1 bcf GPIO,2 main1 bsf GPIO,0 ; Turn-on LED #1 call pause_250ms ; Pause for 250 miliseconds bcf GPIO,0 ; Turn-off LED #1 bsf GPIO,1 ; Turn-on LED #2 call pause_250ms ; Pause for 250 miliseconds bcf GPIO,1 ; Turn-off LED #2 bsf GPIO,2 ; Turn-on LED #3 call pause_250ms ; Pause for 250 miliseconds bcf GPIO,2 ; Turn-off LED #3 goto main1 ;-----[Subroutines]---------------------------------------------------------- pause_250ms ; This subroutine delays for ~250 milliseconds movlw d'249' ; Move the literal count of 249 to reg 'W' movwf COUNT ; ...then store it in the register 'COUNT' goto pause pause ; This subroutine pauses for 1 millisecond movlw d'100' ; Move the literal count of 100 to reg 'W' movwf COUNT1 ; ...then store it in the register 'COUNT1' pause_1 NOP ; These 7 'NOP's delay for 7 microseconds NOP NOP NOP NOP NOP NOP decfsz COUNT1,F ; Is the buffer 'COUNT1' decrement to zero? goto pause_1 ; ...no, its not fully decremented yet, loop again decfsz COUNT,F ; ...yes, now decrement the buffer 'COUNT' goto pause ; The buffer 'COUNT' is not zero, load 'COUNT1' again retlw 0 ; ...Yes, now the buffer COUNT' is zero. Return. END ; Directive to end the program
發表於: 2005/6/17 7:18
|
|||
|