RT
查看手册,描述如下
但在测试时出现如下波形:
如果手动将TX脚配置为输出,则波形正常,如下:
同时,如果在硬件上TX脚加上拉电阻,波形也是正常的,如图2.
但是官方笔记中的示例代码却是将TX脚置为输入,代码如下:
SetupSerial: Bank1 ;select bank 1
movlw 0xc0 ;set tris bits for TX and RX
iorwf TRISC,F
movlw SPBRG_VAL ;set baud rate
movwf SPBRG
movlw 0x24 ;enable transmission and high baud rate
movwf TXSTA
Bank0 ;select bank0
movlw 0x90 ;enable serial port and reception
movwf RCSTA
clrf Flags ;clear all flag bits
call InitTxBuffer ;initialize transmit buffer
call InitRxBuffer ;initialize receive buffer
movlw 0xc0 ;enable global and peripheral ints
movwf INTCON
Bank1 ;select bank1
movlw 0x30 ;enable TX and RX interrupts
movwf PIE1
return
很糊涂,求解!
|