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


Browsing this Thread:   1 Anonymous Users






请教pic16f73 USART串口异步通讯问题
#1
新會員
新會員


查看用戶資訊
ORG 0x000
GOTO START
ORG 0x004 ;中断服务程序
BCF PIR1,RCIF ; 清中断标志
NOP ;保护现场 略
; MOVF RCREG,W ;读接收数据 略
NOP
NOP
MOVLW 0x00 ;
NOP
NOP
MOVWF 0x6 ;B口输出低点亮发光二极管
NOP
NOP
NOP
BCF 0x7,5 ;PORTC.5为低发光二极管亮
NOP
NOP
CLRF PIR1 ;清中断标志
NOP
;回复现场 略
RETFIE ;中断返回

ORG 0x100
START NOP ;主程序
CALL PIC_INIT ;调USART串口异步接收
;初始化
LOOP2 NOP ;主程序在这里死循环,中断时
;应能跳出并返回
NOP
NOP
NOP
GOTO LOOP2 ;主程序在这里死循环
PIC_INIT NOP ;串口接收初始化
NOP
; BCF STATUS,RP0 ; 选择BANK0
CLRF 0x06
BSF STATUS,RP0 ; 选择BANK1
MOVLW B'00000000'
MOVWF TRISB ;B口方向为输出
NOP
MOVLW 0x0ff ;B口8位为高,灯熄灭
MOVWF 0x6
CLRF 0x7
BSF STATUS,RP0 ;选择BANK1
MOVLW B'10000000'
MOVWF TRISC ;端口C方向,RC7/RX/DT为输入,RC0-RC6为输出。PORT C direction
BSF 0x7,5 PORTC.5为高灯息灭
MOVLW 0x12 ;送波特率9600 bps @ 12MHZ,Async, BRGH=1
MOVWF SPBRG ;送波特率
;MOVLW B'00100100'
; MOVWF TXSTA ;发送使能、8位、异步模式 8 Bit, Async Mode, Enable
; BSF INTCON,PEIE ;外围接口中断使能位
; BSF PIE1,TMR2IE ;TMR2到PR2匹配中断使能
;这几条去掉了,接收初始化发送的不写了
;BSF STATUS,RP0 ;选择BANK0
;置RC6\RC7为低电平,没写。
; MOVLW B'00100100'
; MOVWF TXSTA ;发送使能8 Bit, Async Mode, Enable
BCF STATUS,RP0 ;下面开始写了
MOVLW B'10010000' ;接收使能
MOVWF RCSTA ;8 Bit,Async Mode, Enable
CLRF INTCON
BSF INTCON,PEIE ; 外围接口中断使能
BSF STATUS,RP0
CLRF PIE1
BSF PIE1,RCIE ;开接收中断
MOVLW 0x0C0
MOVWF INTCON ;开外围接口中断和总中断
; BCF STATUS,RP0
; BSF INTCON,GIE ;开总中断
RETURN
END
发送单片机波特率与接收单片机同
MOVLW 0x12 ;送波特率9600 bps @ 12MHZ,Async, BRGH=1
MOVWF SPBRG ;送波特率
程序设计成循环连续发送,在发送单片机TX—17脚能测到方波,周期约50微秒。上面的程序把亮灯指令放到主程序中,灯能点亮,放到中断服务程序中灯不能点亮,好像中断没响应,中断的三道开关我都打开了
BSF PIE1,RCIE ;开接收中断
MOVLW 0x0C0
MOVWF INTCON ;开外围接口中断和总中断
不知道中断为什么不响应?
请教各位老师,各位年轻年长的老先生?

發表於: 2008/11/17 9:55
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... ]

教育訓練中心

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