|
|||||||||||
| 技術(shù)交流 | 電路欣賞 | 工控天地 | 數(shù)字廣電 | 通信技術(shù) | 電源技術(shù) | 測(cè)控之家 | EMC技術(shù) | ARM技術(shù) | EDA技術(shù) | PCB技術(shù) | 嵌入式系統(tǒng) 驅(qū)動(dòng)編程 | 集成電路 | 器件替換 | 模擬技術(shù) | 新手園地 | 單 片 機(jī) | DSP技術(shù) | MCU技術(shù) | IC 設(shè)計(jì) | IC 產(chǎn)業(yè) | CAN-bus/DeviceNe |
小弟寫了一個(gè)程序 請(qǐng)大蝦們看看是否有問題 |
| 作者:newer_zhk 欄目:單片機(jī) |
小弟寫了一個(gè)程序 因?yàn)樾酒悬c(diǎn)問題 要直接燒寫 請(qǐng)大蝦們看看是否有問題 要實(shí)現(xiàn)的是個(gè)產(chǎn)生個(gè)數(shù)據(jù)發(fā)生器 中斷一次就發(fā)下一個(gè)數(shù)據(jù)一次 list p=16F628A ; list directive to define processor #include <p16F628A.inc> ; processor specific variable definitions errorlevel -302 ; suppress message 302 from list file ; __CONFIG _CP_OFF & _DATA_CP_OFF & _LVP_OFF & _BOREN_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON & _INTOSC_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 0x71 ; variable used for context saving status_temp EQU 0x72 ; variable used for context saving ;定義主程序用寄存器 count EQU 0x74 ; 定義計(jì)數(shù)寄存器地址 tmp1 EQU 0x75 ; 定義臨時(shí)寄存器地址 x EQU 0x76 ; 延時(shí)子程序外循環(huán)計(jì)數(shù)器 y EQU 0x77 ; 延時(shí)子程序內(nèi)循環(huán)計(jì)數(shù)器 tmp2 EQU 0x78 count1 EQU 0x79 SCK EQU 2 ;RB2 SDI EQU 3 ;RB3 SWITCH EQU 4 ;RB4 ;********************************************************************** ORG 0x000 ; processor reset vector nop goto main ; go to beginning of program ORG 0x004 ; interrupt vector location bcf PORTB,SWITCH retfie 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 ;****************************************************** main ;****************************************************** init CLRF INTCON CLRF PORTA ;Initialize PORTA and PORTB by CLRF PORTB ;setting OUTPUT data latches MOVLW 0x07 ;Turn comparators off and MOVWF CMCON ;enable pins for I/O ;functions BCF STATUS, RP1 BSF STATUS, RP0 ;SELECT Bank1 CLRF PCON BSF PCON,OSCF MOVLW 0x1F ;VALUE used to initialize ;data direction MOVWF TRISA ;Set RA<4:0> as inputs ;TRISA<5> always read as ‘1’. ;TRISA<7:6> depend on oscillator mode CLRF TRISB BSF TRISB,SWITCH CLRF OPTION_REG BSF OPTION_REG,INTEDG ;Interrupt on rising edge of RB0/INT pin BCF STATUS, RP0 ;SELECT Bank0 BSF INTCON,RBIE &nb |
|
|
| 免費(fèi)注冊(cè)為維庫(kù)電子開發(fā)網(wǎng)會(huì)員,參與電子工程師社區(qū)討論,點(diǎn)此進(jìn)入 |
Copyright © 1998-2006 m.58mhw.cn 浙ICP證030469號(hào) |