• 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






Re: 串口通信没反映
#3
新會員
新會員


查看用戶資訊
向电脑发数据,居然都收不到.

發表於: 2008/4/15 13:55
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 串口通信没反映
#2
資深會員
資深會員


查看用戶資訊
關於你寫的這個串口軟件
可以先說說你做過哪些debug的工作嗎??


發表於: 2008/4/15 11:39
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


串口通信没反映
#1
新會員
新會員


查看用戶資訊
帮忙看下单片机串口给计算机发送数据的程序硬件连接是正确的 怎么就是没有反映呢,谢谢各位大大.硬件都连接正确.
;*****************************************************************************

 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  
;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 0x20B'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



發表於: 2008/4/15 9:58
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... ]

教育訓練中心

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