Hi everyone, I am having a big trouble with my PIC's serial communication. I have codes like these: GPS: CALL set4800 A0: CALL RCread CALL TXsend XORLW 'G' BNZ A0 MOVLW 0XFF MOVWF PORTA RETURN I have incoming messages and I want to take the one which starts with 'G', so I write these simple codes. Althoug I have sentences which starts with 'G', PortA never gets FF. I tried these codes with Proteus and it works. But it doesnt work with my pic16f877 in my circuit. From TX output I get the bytes which I sent from RC, I see that there are G's in RC but they dont make the port A to be FF. Please hellllppppp me. Here are my functions: RCread: bcf STATUS,RP0 ; Select Bank 0. getc1 btfss PIR1,RCIF ; Skip if RC int flag set goto getc1 ; Try again movf RCREG,W ; Read the character bcf PIR1,RCIF ; Clear the interrupt flag return TXsend bcf STATUS,RP0 ; Select Bank 0. putc1 btfss PIR1,TXIF ; Skip if TXbuffer empty goto putc1 ; Try again movwf TXREG ; Write it! bcf STATUS,RP0 ; Select Bank 0. return set4800: bsf STATUS,RP0 MOVLW D'51' MOVWF SPBRG movlw 0xA4 ; CSRC/TXEN (Internal clock, 8 bit mode, Async ;operation, High Speed) movwf TXSTA ; Write to TX control register. BSF TXSTA,BRGH BCF STATUS,RP0 ; RETURN
PIC usart problem
Started by ●June 26, 2006
Reply by ●June 26, 20062006-06-26
ali.keles@gmail.com wrote:> Hi everyone, > I am having a big trouble with my PIC's serial communication. I have > codes like these: > GPS: > CALL set4800 > A0: CALL RCread > CALL TXsend > XORLW 'G' > BNZ A0 > > MOVLW 0XFF > MOVWF PORTA > RETURN > I have incoming messages and I want to take the one which starts > with 'G', so I write these simple codes. Althoug I have sentences which > starts with 'G', PortA never gets FF. I tried these codes with Proteus > and it works. But it doesnt work with my pic16f877 in my circuit.The problem may not be with this code (I can't see a bug either). Are you initialising TRISA?> From > TX output I get the bytes which I sent from RC, I see that there are > G's in RC but they dont make the port A to be FF. Please hellllppppp > me. > Here are my functions: > RCread: bcf STATUS,RP0 ; Select Bank 0. > getc1 btfss PIR1,RCIF ; Skip if RC int flag set > goto getc1 ; Try again > movf RCREG,W ; Read the character > bcf PIR1,RCIF ; Clear the interrupt flag > return > > > TXsend bcf STATUS,RP0 ; Select Bank 0. > putc1 btfss PIR1,TXIF ; Skip if TXbuffer empty > goto putc1 ; Try again > movwf TXREG ; Write it! > bcf STATUS,RP0 ; Select Bank 0. > return > set4800: bsf STATUS,RP0 > MOVLW D'51' > MOVWF SPBRG > movlw 0xA4 ; CSRC/TXEN (Internal clock, 8 bit mode, > Async > ;operation, > High Speed) > movwf TXSTA ; Write to TX control register. > BSF TXSTA,BRGH > BCF STATUS,RP0 ; > RETURN
Reply by ●June 27, 20062006-06-27
Hi, Hope you have configured the PORTA as only digital, check the ADCON0 and ADCON1 register'' toby wrote:> ali.keles@gmail.com wrote: > > Hi everyone, > > I am having a big trouble with my PIC's serial communication. I have > > codes like these: > > GPS: > > CALL set4800 > > A0: CALL RCread > > CALL TXsend > > XORLW 'G' > > BNZ A0 > > > > MOVLW 0XFF > > MOVWF PORTA > > RETURN > > I have incoming messages and I want to take the one which starts > > with 'G', so I write these simple codes. Althoug I have sentences which > > starts with 'G', PortA never gets FF. I tried these codes with Proteus > > and it works. But it doesnt work with my pic16f877 in my circuit. > > The problem may not be with this code (I can't see a bug either). Are > you initialising TRISA? > > > From > > TX output I get the bytes which I sent from RC, I see that there are > > G's in RC but they dont make the port A to be FF. Please hellllppppp > > me. > > Here are my functions: > > RCread: bcf STATUS,RP0 ; Select Bank 0. > > getc1 btfss PIR1,RCIF ; Skip if RC int flag set > > goto getc1 ; Try again > > movf RCREG,W ; Read the character > > bcf PIR1,RCIF ; Clear the interrupt flag > > return > > > > > > TXsend bcf STATUS,RP0 ; Select Bank 0. > > putc1 btfss PIR1,TXIF ; Skip if TXbuffer empty > > goto putc1 ; Try again > > movwf TXREG ; Write it! > > bcf STATUS,RP0 ; Select Bank 0. > > return > > set4800: bsf STATUS,RP0 > > MOVLW D'51' > > MOVWF SPBRG > > movlw 0xA4 ; CSRC/TXEN (Internal clock, 8 bit mode, > > Async > > ;operation, > > High Speed) > > movwf TXSTA ; Write to TX control register. > > BSF TXSTA,BRGH > > BCF STATUS,RP0 ; > > RETURN
Reply by ●June 29, 20062006-06-29
<ali.keles@gmail.com> wrote in message news:1151333610.439573.258960@u72g2000cwu.googlegroups.com...> Hi everyone, > I am having a big trouble with my PIC's serial communication. I have > codes like these:Try following the examples on www.piclist.com and then expand on them. :) You can get some pretty good bitrates out of the 40Mhz PICs clocked at 60Mhz but have to guess the divisor-thingies almost (thoroughly untechnical term I know).