帮忙看下单片机串口给计算机发送数据的程序硬件连接是正确的 怎么就是没有反映呢,谢谢各位大大.硬件都连接正确.
;*****************************************************************************
list p=16F688 ; list directive to define processor
#include p16F688.inc ; processor specific variable definitions
errorlevel -302 ; suppress message 302 from list file
__CONFIG _FCMEN_OFF&_IESO_OFF&_BOD_OFF&_CPD_OFF&_CP_OFF&_PWRTE_OFF&_WDT_OFF&_INTRC_OSC_CLKOUT&_MCLRE_ON
#define bank0 bcf STATUS,RP0
#define bank1 bsf STATUS,RP0
;***** VARIABLE DEFINITIONS*****************************************
w_temp equ 0x70 ; variable used for context saving
status_temp equ 0x71 ; variable used for context saving
isr_temp equ 0x72 ; used to determine the interrupt source
TxData equ 0x7A
STATE equ 0x7D ; State machine
flg equ 0x7F ; various flags
circle equ 0x80
even EQU 0 ;1 = data from UART was returned in W
;*************************************************************************
; Pin Declarations
TX equ 04h ;TX pin
RX equ 05h ;RX pin
;*************************************************************************
; Constant Declarations
ORG 0x000 ; processor reset vector
clrf STATUS
goto main ; go to beginning of program
ORG 0x004 ; interrupt vector location
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 regist
goto isr
main
call Init
call USART_INIT
CLRF TXREG
movlw .9
movwf circle
nextchar
call tx_char
decfsz circle,w
goto nextchar
goto $
Init
bank1
clrf flg;
clrf STATE ;initialize state machine
bsf OSCCON,SCS
movlw b'01100000'
iorwf OSCCON ;Set INTOSC to 4MHz
clrf ANSEL ;将引脚配置为I/O口
movlw 0xFF
movwf TRISA ;把PORTA配置为输入
bsf TRISC,RX ;RX引脚配置为输入
bcf TRISC,TX ;TX引脚配置为输出
; movlw 0x20; B'00100000'
;movwf PIE1 ;Int on Rx (RCIE)
bank0
clrf PORTA
clrf PORTC
;movlw 0xC0 ;B'11000000' ;GIE,PEIE
;movwf INTCON;全局中断,外设中断允许
RETURN
isr
nop
nop
return
USART_INIT
bank0
movlw .51 ; Default 1.2Kbaud @ 4MHz 可以查表得到,注意参数的0或1 P98
movwf SPBRG
bcf TXSTA,BRGH ; Low
bcf TXSTA,SYNC ; Async mode
bcf TXSTA,TX9 ; 9 bit data for parity
bsf TXSTA,TXEN ; enable transmitter
bsf RCSTA,SPEN ; Serial Port Enable
;bsf RCSTA,CREN ; Continuous Receive Enable
;bcf RCSTA,RX9 ; 9 bit data for parity
bcf BAUDCTL,BRG16 ; 16 bit BRG
movf RCREG,w ; read RCREG to clear any pending IRQ=Interrupt Request
return
;------------------ Transmit Character ------------------------
tx_char
; transmit the character in W ParityByte CalcParity
bank0
tx_lp
btfss PIR1,TXIF ; TX Buffer Empty?
goto tx_lp ; Check again...
movwf TXREG
banksel TXSTA
btfss TXSTA,TRMT ;wait for data TX
goto $-1
return