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.

PIC USART problem- only works after a master clear reset

Status
Not open for further replies.

snilson

Newbie level 3
Joined
May 23, 2008
Messages
4
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,307
usart on pic ide

Hi,

I'm using the 16F648 usart but I'm facing a big problem: the program only works after a master clear reset... any help on this?

thanks
 

pÄ°c usart reset problem

hi!

here goes an excert of the code

Code:
   	org     0x00				
   	goto    START

START

	BANK0   	        		
	
	movlw	0x07
	movwf	CMCON				; port A = I/O

   	clrf	PORTA				
   	clrf	PORTB				

	BANK1   	        		

	bsf		OPTION_REG,7		; disables port B pull ups

	movlw	B'00000000'			;
	movwf	TRISA				; RA3 -> A1 multiplexer, RA2 -> A0 multiplexer, RA1 -> Busy, RA0 -> Idle
	
	movlw	B'00010110'			;
	movwf	TrisRS				; (RS232)    RB1 <- RX, RB2 <- TX, RB5 -> RTS, RB4 -> Buzzer
						
	BANK0

	bsf		PortStatus,BUSY

    call    Config_usart		; config USART
	
	movlw	'A'
	call	Trs_byte			; sends the byte in WREG

	....


STANDBY
	nop
	goto	STANDBY


Config_usart

    BANK1	   			
	movlw	240			; 4800@18.432MHz BRGH=1
    movwf   SPBRG	    
	bsf    	TXSTA,BRGH	

    BANK0  		        
  	bsf    	RCSTA,SPEN  ; habilita porta série

    BANK1 		        
	bcf    	TXSTA,SYNC  ; selecciona modo assíncrono
    bcf    	TXSTA,TX9   ; habilita transmissão de 8 bits
    bsf    	TXSTA,TXEN  ; habilita transmissão
	
    BANK0  		        
  	bcf    	RCSTA,RX9   ; habilita recepção de 8 bits
    bsf    	RCSTA,CREN  ; habilita recepção
	bcf		RCSTA,ADEN	; desabilita detecção de endereços
	
    return

Trs_byte
	BANK1          		
    btfss	TXSTA,TRMT    	; verifica se não existem dados no registo de transmissão
    goto    $-1
	BANK0
    btfss	PIR1,TXIF    	; verifica se não existem dados no buffer de transmissão
    goto    $-1
   	movwf   TXREG  			; transmite byte

	return


    END

the configuration bits are set on the IDE and only the master clear is enabled.

thanks
 

16f648 usart

Cool. Not only is it the typically hard to figure out ASSEMBLY language. The comments are hard to get too!!:D

Not being too familiar with the controller (or the language !), Id take a stab and say

"I can't see where this loops back around for another pass".
So a one shot operation would seem like what would happen.

But thats just a S W A G 8O
 

PIC USART problem

Assalamo Allykum !

Dear its difficult to understand the Assembly Language.

Even you comments are not in English.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top