Use the serial port debugging wizard or the PC's hyperterminal to debug the serial port program

Publisher:BlissfulWhisperLatest update time:2010-09-29 Keywords:PC Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

;Use the serial port debugging wizard or the PC terminal's hyperterminal, set the baud rate to 9600, 8 data bits,
1 stop bit, no parity bit.
;First, send a character such as "2" from the PC to the serial port. After receiving it, the microcontroller returns the received number such as "2-PIC16" to the computer.
;Note the settings of the experimental board: S4, S5, S1 must all be OFF, and S13 pins 6 and 7 must be ON.
;When burning, pay attention to the oscillation mode XT, and WDT must be disabled.
LIST P=16F877
INCLUDE "P16F877.INC"
;***************************************
__CONFIG _DEBUG_OFF&_CP_ALL&_WRT_HALF&_CPD_

ON&_LVP_OFF&_BODEN_OFF&_PWRTE_ON&_WDT_OFF&_HS_OSC;
;************************
CBLOCK 0x20
TXBUFF :9
TXPTR
TXCOUNT
RXBUFF :9
PUTPTR
GETPTR
STATUS_TEMP
FSR_TEMP
ENDC

W_TEMP EQU 7FH
;-------------------------
ORG 0X000
GOTO MAIN
;---------------- ---------
ORG 0X004
GOTO INT
ORG 0X008
INT
MOVWF W_TEMP
SWAPF STATUS,W
CLRF STATUS
MOVWF STATUS_TEMP
MOVFW FSR
MOVWF FSR_TEMP
CHKRXINT
BANKSEL PIR1
BTFSS PIR1,RCIF
GOTO CHKTXINT
_RDRXFIFO
BTFSC RCSTA,FERR
GOTO _FERR_PRO
MOVLW RXBUFF
MOVWF FSR
MOVF PUTPTR,W
ADDWF FSR,F
MOVF RCREG,W
MOVWF INDF
INCF PUTPTR,F
MOVLW .7
ANDWF PUTPTR,F
BTFSC PIR1,RCIF
GOTO _RDRXFIFO
BTFSS RCSTA,OERR
GOTO ENDOFINT
_OERR_PRO
BCF RCSTA,CREN
BSF RCSTA,CREN
GOTO ENDOFINT
_FERR_PRO
MOVF RCREG,W
GOTO ENDOFINT
;---------------------
CHKTXINT
BSF STATUS,RP0
BTFSS PIE1,TXIE
GOTO ENDOFINT
BCF STATUS,RP0
BTFSS PIR1,TXIF
GOTO ENDOFINT
MOVLW TXBUFF
MOVWF FSR
MOVF TXPTR,W
ADDWF FSR,F
MOVF INDF,W
MOVWF TXREG
INCF TXPTR,F
DECFSZ TXCOUNT,F
GOTO ENDOFINT
BSF STATUS ,RP0
BCF PIE1,TXIE
BCF STATUS,RP0
ENDOFINT
CLRF STATUS
MOVFW FSR_TEMP
MOVWF FSR
SWAPF STATUS_TEMP,W
MOVWF STATUS
SWAPF W_TEMP,F
SWAPF W_TEMP,W
RETFIE
;-------------------

MAIN
BANKSEL TXSTA
MOVLW B'00100100'
MOVWF TXSTA
MOVLW .25
MOVWF SPBRG
CLRF PIE1
BSF PIE1,RCIE
CLRF STATUS
CLRF TXCOUNT
CLRF GETPTR
CLRF PUTPTR
MOVLW B'10010000'
MOVWF RCSTA
CLRF INTCON
BSF INTCON,PEIE
BSF INTCON,GIE
LOOP
CALL CHECK_DATA
GOTO LOOP
;----------------------
CHECK_DATA
CLRF STATUS
MOVF TXCOUNT,W
SKPZ
RETURN
MOVF GETPTR,W
XORWF PUTPTR,W
SKPNZ
RETURN
MOVLW RXBUFF
MOVWF FSR
MOVF GETPTR,W
ADDWF FSR,F
INCF GETPTR,F
MOVLW .7
ANDWF GETPTR,F
MOVF INDF,W
MOVWF TXBUFF+0
MOVLW 'P'
MOVWF TXBUFF+1
MOVLW 'I'
MOVWF TXBUFF+2
MOVLW 'C'
MOVWF TXBUFF+3
MOVLW 'A'
MOVWF TXBUFF+4
MOVLW 'V'
MOVWF TXBUFF+5
MOVLW 'R'
MOVWF TXBUFF+6
MOVLW 0X0D
MOVWF TXBUFF+7
MOVLW 0X0A
MOVWF TXBUFF+8
MOVLW .9
MOVWF TXCOUNT
CLRF TXPTR
BSF STATUS,RP0
BSF PIE1,TXIE
BCF STATUS,RP0
RETURN
;- --------------------
END

Keywords:PC Reference address:Use the serial port debugging wizard or the PC's hyperterminal to debug the serial port program

Previous article:Design of Laser Password Controller Based on AT89C51
Next article:Software UART Design Based on the Universal Pins of Single-Chip Microcomputer

Recommended ReadingLatest update time:2024-11-17 00:09

After the emergence of PC and mobile Internet, the next standardized device may be a robot
At the 6th World Internet Conference, Cheetah Mobile CEO Fu Sheng pointed out in his speech that after the emergence of PC and mobile Internet, the next standardized device may be a robot. Fu Sheng said that the essence of the Internet is data-driven, "not because Jack Ma and Pony Ma have 'three heads and six arms',
[Embedded]
The evolution and survival of PC
Preface Back on January 27, 2010, a very great thinker declared the death of the PC (personal computer). Ten years later, the PC is still alive and well, although a time traveler from 2010 would not recognize it. This is undoubtedly how this "endangered species" evolves and survives.   text   It wasn’t that long ago
[Embedded]
The evolution and survival of PC
Chip price increases snowball from components to PC consumers
A global chip shortage is causing price increases for electronics such as laptops and printers and could hit other hot-selling products such as smartphones. Suppliers say the cost increases are in some cases being passed on to consumers. According to the Wall Street Journal, suppliers and key material suppliers for ch
[Mobile phone portable]
Picotech PC802 5G small base station baseband SoC is gaining momentum, and several customers have completed prototype designs based on it
Hangzhou, China - July 25, 2022 - Picocom, a provider of 5G small base station baseband chips and telecom-grade software, is pleased to announce that since its launch in December last year, its PC802 chip has been selected by more than a dozen customers and three of them have recently completed the 5G small
[Network Communication]
Picotech PC802 5G small base station baseband SoC is gaining momentum, and several customers have completed prototype designs based on it
Description of the USB (D12) data communication process between PC and MCU
When communicating with netizens about the development experience of D12, I found that some netizens were confused about the process of data exchange between PC application software and MCU. They did not understand how PC application software sent data to MCU and how MCU sent data to PC application software through D12
[Microcontroller]
Analysis of the Internal Structure of PC Power Supply
The best way to see what the power supply is made of is to open the shell of the power supply and take a look at the internal structure of the power supply. The second method is to package four diodes together. The latter method is called a full bridge. The minimum withstand voltage and maximum cu
[Power Management]
From PC bus to ARM internal bus
When I was studying Chapter 9 and Hardware Communication in "Linux Device Drivers (3rd Edition)", I was not very clear about the concept of IO bus, so I looked for relevant information. Now I summarize it as follows: References for this article: 1. "Introduction to AMBA, AHB, APB Buses" Author: adamzhao Date: 2006-11
[Microcontroller]
Design of Digital Voltmeter Based on PC
There are many types and styles of digital voltmeters in design and development. Traditional digital voltmeters have their own characteristics. They are suitable for manual measurement on site. Traditional digital voltmeters cannot complete remote measurement and further analyze and process the measured data. Howeve
[Microcontroller]
Design of Digital Voltmeter Based on PC
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号