Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

I need help with PIC16F877A communicate with hyperterminal

Status
Not open for further replies.

kenny90

New Member
Hi, I'm facing a problem that the data program inside the PIC16F877A did not display out at hyperterminal. i'm using RS232 to USB converter connect with my laptop.

I have question :
1) i'm using window 7, i have already download hyperterminal software and use it. It is a problem that window 7 did not support the hyperterminal software so that it can't display out.

2) Below code i have build it succesfully. It's there anything wrong with the code that cause it did not display.




LIST P=16F877A
PROCESSOR 16f877a
#include <P16F877A.INC> ; Include header file
__CONFIG _CP_OFF & _DEBUG_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _PWRTE_ON & _WDT_OFF & _XT_OSC

CBLOCK 0x20 ; Declare variable addresses starting at 0x20
dataL
ENDC

org 0x0000
goto START
org 0x0010
START
bsf STATUS,RP0 ; RAM PAGE 1
movlw b'00000000' ; set up TRISC
movwf TRISC

;Boot Baud Rate = 9600, No Parity, 1 Stop Bit
;
movlw d'129' ; 0x19=9600 bps (0x0C=19200 bps)
movwf SPBRG
movlw b'00100100' ; brgh = high (2)
movwf TXSTA ; enable Async Transmission, set brgh

bcf STATUS,RP0 ; RAM PAGE 0

movlw b'10010000' ; enable Async Reception
movwf RCSTA

; PROVIDE A SETTLING TIME FOR START UP
; ------------------------------------
;
clrf dataL
settle decfsz dataL,F
goto settle

movf RCREG,W
movf RCREG,W
movf RCREG,W ; flush receive buffer
;
; ---------
; MAIN LOOP
; ---------
;
call message ; send "16F628 alive"
loop call receive ; wait for a char
call send ; send the char
goto loop
;
; -------------------------------------------
; RECEIVE CHARACTER FROM RS232 AND STORE IN W
; -------------------------------------------
; This routine does not return until a character is received.
;
receive
btfss PIR1,RCIF ; (5) check for received data
goto receive

movf RCREG,W ; save received data in W
return
;
; -------------------------------------------------------------
; SEND CHARACTER IN W VIA RS232 AND WAIT UNTIL FINISHED SENDING
; -------------------------------------------------------------
;
send movwf TXREG ; send data in W

TransWt
bsf STATUS,RP0 ; RAM PAGE 1
WtHere
btfss TXSTA,TRMT ; (1) transmission is complete if hi
goto WtHere

bcf STATUS,RP0 ; RAM PAGE 0
return
;
; -------
; MESSAGE
; -------
;
message movlw '1'
call send
movlw '6'
call send
movlw 'F'
call send
movlw '8'
call send
movlw '7'
call send
movlw '7'
call send
movlw 'a'
call send
movlw ' '
call send
movlw 'w'
call send
movlw 'o'
call send
movlw 'r'
call send
movlw 'k'
call send
movlw 'i'
call send
movlw 'n'
call send
movlw 'g'
call send
movlw 0x0D ; CR
call send
movlw 0x0A ; LF
call send
return

END
 
A quote from the manual,
Bit SPEN (RCSTA<7>) and bits TRISC<7:6> have to be
set in order to configure pins RC6/TX/CK and RC7/RX/DT
as the Universal Synchronous Asynchronous Receiver
Transmitter.

You are clearing the trisc register.

I haven't checked the rest of the code so there may be other errors.

Mike.
 
A quote from the manual,


You are clearing the trisc register.

I haven't checked the rest of the code so there may be other errors.

Mike.

THANK for reply, That mean i have to set

movlw b'11000000'
movwf TRISC

so that the RC6 and RC7 as input
 
Correct.

Mike.

THANK Mike, i have tried it and i use multimeter to measure the pin 25 RC6/TX and 26 RC7/RX.
RC6/TX did not have voltage pass through while RC7/RX have.

this mean that RC6/TX did not communicate with PIC16f877a?

**broken link removed**
above link is the schematic and the microcontroller i change to PIC16f877a.
 
connect pin 11 and 12 together on the MAX232, then try typing some data into hyper terminal, you should start seeing what you typed showing up on the screen, if you disconnect pin 11 from 12 then as you type data into hyper terminal you should not see any output,

If it is not like this try connecting pin 14 and 13 together, then note down if you get output or not. If you don't make sure you havesetup hyper terminal correctly, it should be no parity and no flow control

Tell us your findings, if you see output it is something wrong with your PIC, not the TTL to RS232 converter, RS232 to USB converter, or your computer

also if it works try a bit of code to make sure your PIC is running, like flashing an LED or something
 
connect pin 11 and 12 together on the MAX232, then try typing some data into hyper terminal, you should start seeing what you typed showing up on the screen, if you disconnect pin 11 from 12 then as you type data into hyper terminal you should not see any output,

If it is not like this try connecting pin 14 and 13 together, then note down if you get output or not. If you don't make sure you havesetup hyper terminal correctly, it should be no parity and no flow control

Tell us your findings, if you see output it is something wrong with your PIC, not the TTL to RS232 converter, RS232 to USB converter, or your computer

also if it works try a bit of code to make sure your PIC is running, like flashing an LED or something

hi micr0man, thx for giving this advice.....it really works....actually i connect the pin 2 and pin 3 which are TX and RX of the RS232 to USB converter to make sure that whenever i type it will showing on screen. if din showing then may b probably ur RS232 to USB is spoil or u din correctly install ur driver....and my problem is my RS232 to USB is spoil.
i bought a new wan and can run on hyperterminal...
thx micr0man....^^
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top