Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

UART is displaying unexpected characters

Status
Not open for further replies.
Dear All,
My above codes working well with Proteus, But it does not working with actual hardware which I made myself

Hardware connection

RC6 to pin 11 of max232
Rc7 to pin 12 of max232

pin 13 of max232 to pin 3 of DB9
pin 14 of max 232 to pin 2 of DB9

pin 5 of DB9 is connected to GND

Communication with windows XP, using puTTy software

Please help
Thanks in advance
 

Post a schematic of the MAX232 circuit you are using
 
  • Like
Reactions: PA3040

    PA3040

    Points: 2
    Helpful Answer Positive Rating
The capacitor in pin #6 is reversed, pin 6 is negative compared to the GND so the - of the cap goes to pin 6 and + to GND
 
  • Like
Reactions: PA3040

    PA3040

    Points: 2
    Helpful Answer Positive Rating
Dear Alex Thanks for the reply

Sorry for delay to respond
Please see the attached for cct
Please advice

- - - Updated - - -

Dear Bigdog Thanks for the reply

Actually unexpected characters came earlier when I simulated with Proteus, but now I am using actual hardware. it dose not receive any characters
Please advice

- - - Updated - - -

Dear jayanth.devarayanadurga,

Still I could not changed the IC. I will let you know after change it

Thanks for the reply
 

Attachments

  • rtc_new.pdf
    16.2 KB · Views: 59

The capacitor in pins 4 and 5 is also reversed
 
  • Like
Reactions: PA3040

    PA3040

    Points: 2
    Helpful Answer Positive Rating
Hi,

Just looking at your circuit, it seems you have the cap on pins 4 and 5 the wrong way round.

According to the max232 datasheet if it is a max232 chip it should have 1uf caps not 10uf, or if its a max232a it should be 0.1uf
( though not sure but it may still work with 10uf..??)

Alway best to fit a 100nf across pins 31 and 32 of the 877a.

Not too clear from the diagram, assume something is pulling up Mclre when not conencted to icsp ?
 
  • Like
Reactions: PA3040

    PA3040

    Points: 2
    Helpful Answer Positive Rating
Dear All,
Thanks for the reply
I corrected all 10uf Capacitors as you advised. but still problem remaining unchanged

Code:
char_loader	equ			0x20
char_reciver	equ		0x21	
LIST P=P16F877
#include <p16f877a.inc>
__config 3f39

			org	0x000
start		goto	main
main		call	sys_init
loop		call	load_char
			goto	loop			

load_char	movlw	'T'
			movwf	char_loader
			call	send_char
			movlw	'E'
			movwf	char_loader
			call	send_char
			movlw	'S'
			movwf	char_loader
			call	send_char
			movlw	'T'    
			movwf	char_loader
			call	send_char
			movlw	'1'
			movwf	char_loader
			call	send_char
			movlw	'2'
			movwf	char_loader
			call	send_char
			return
			
send_char	btfss	PIR1,TXIF			;Check the USART transmit buffer is empty
			goto	$-1
			movf	char_loader,w
			movwf	TXREG
			return
			
sys_init	clrf	PORTB
			bsf		STATUS,5
			movlw	b'10000000'		
			movwf	TRISC
			movlw	0x19
			movwf	SPBRG			; Set Baud rate 9600bps
			movlw	b'10100100'		; 8-bit transmit, transmitter enabled,
			movwf	TXSTA			; asynchronous mode, low speed mode
			clrf	TRISB
			bcf		STATUS,5
			bsf		RCSTA,SPEN			;Serial port enabled 
									;(configures RC7/RX/DT and 
									;RC6/TX/CK pins as serial port pins)
			movlw	b'10010000'
			movwf	RCSTA
			return				



end

Please advice
 

Attachments

  • putty.JPG
    putty.JPG
    17.6 KB · Views: 63

What is the voltage in pins 2 and 6 referred to the ground?

Are you sure that this is not a fault of the uard code in the mcu ?
 

Hi,

Your code does work in ISIS but not sure about the values you have assigned to the Usart TXSTA

Assume you are using a 4mhz crystal ?

Have used my standard usart init routine that I know works on hardware ok.

There is no need to move your data, movlw 'T' to a separate register, the Usart picks up the value from W as nothing changes it.

Also add a little delay after sending the string of data so you can see it more clearly.
Code:
char_loader	equ			0x20
char_reciver	equ		0x21	
	LIST P=16F877a
	#include <p16f877a.inc>
	__config 3f39

			org	0x000
start		goto	main
main		call	sys_init
loop		call	load_char
			goto	loop			

load_char	movlw	'T'
;			movwf	char_loader
			call	send_char
			movlw	'E'
;			movwf	char_loader
			call	send_char
			movlw	'S'
;			movwf	char_loader
			call	send_char
			movlw	'T'    
;			movwf	char_loader
			call	send_char
			movlw	'1'
;			movwf	char_loader
			call	send_char
			movlw	'2'
;			movwf	char_loader
			call	send_char
;			call	delay500ms			; add in a little delay to slow the messages down a bit

			return
			
send_char	btfss	PIR1,TXIF			;Check the USART transmit buffer is empty
			goto	$-1
;			movf	char_loader,w
			movwf	TXREG
			return
			
sys_init	clrf	PORTB
			bsf		STATUS,5
			movlw	b'10000000'		
			movwf	TRISC
;			movlw	0x19
;			movwf	SPBRG			; Set Baud rate 9600bps
;			movlw	b'10100100'		; 8-bit transmit, transmitter enabled,
;			movwf	TXSTA			; asynchronous mode, low speed mode
;			clrf	TRISB
;			bcf		STATUS,5
;			bsf		RCSTA,SPEN			;Serial port enabled 
									;(configures RC7/RX/DT and 
									;RC6/TX/CK pins as serial port pins)
;			movlw	b'10010000'
;			movwf	RCSTA




			movlw   d'25'               ; 9600 baud @ 4 Mhz Fosc  8 bit Async	
			banksel SPBRG	
     		movwf   SPBRG				; BRGH=1	
     		movlw   b'00100100'           
     		movwf   TXSTA               ;enable Async Transmission, set brgh
			banksel 0
     		movlw   b'10010000'
     		movwf   RCSTA               ;enable Async Reception
           	return	



			end
 
  • Like
Reactions: PA3040

    PA3040

    Points: 2
    Helpful Answer Positive Rating
Dear wp100 Really thanks for the reply and additional advice

I checked the MAX232 pin voltage again the datasheet
I observed following reading

PIN no 2, 4.7v ( + )
PIN no 6, 3.7v ( + )

As per datasheet it should be +10v and -10v

As per the above data, I think better way change the MAX 232 IC first.

Please advice
Thanks in advance
 

Use lower capacitor values too, the 10uf may be the cause of the problem stressing the internal charge pump
 
  • Like
Reactions: PA3040

    PA3040

    Points: 2
    Helpful Answer Positive Rating
Hi,

No idea of the exact voltages the max232 produces but seems to remember its always a good bit lower than the figures they quote.

If you have a Pickit2 /Clone /diy you can uses the V2.61 PK2 USART tool to act as the PC, so bypassing the max232 chip.
 

Just measured a max232CPE (1uf caps) with just power supply (no Tx/Rx) and I got -9.61, +9.78
 
  • Like
Reactions: PA3040

    PA3040

    Points: 2
    Helpful Answer Positive Rating
Dear All Thanks for the replies,

Now it is working
I changed the MAX 232n, without changing Capacitors. suppose to change capacitors tomorrow
PIN no 2 = + 8.89
PIN no 6 = - 8.36

Previously I used MAX 232cpe
I think there is no big different between MAX 232cpe and max232n
I need to more improve this further, then I will let you know.

- - - Updated - - -

Hi
Dear wp100, Thanks for the reply
I applied the delay subroutine as you advised, then it isn't working (SORRY NOW IT IS WORKING)
Please advice
 
Last edited:

Dear All,
Now my USART Program is working

So my laptop does not have serial port ( DB9). Can I able connect this using USB to serial converter cable with my laptop

Please advice me before buy the USB to serial converter
Is it possible to prepare it myself ?

Please advice
Thanks in advance
 

Yes. You can use USB to Serial Adapter (Breakout Board). You can get it from SparkFun.

Dear jayanth, Thanks for the reply

I mean simple USB to serial converter which is just locally available one

Breakout board, Is this special kind of board

Currently I am using PuTTy for PC interface. If I used USB to serial converter then, can I use PuTTy ?

Please advice
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top