You must use a "bytes_to_be_sent" byte that will tell your app how many bytes he has to wait until receiving the carriage return. This is because if your code sends a data IDENTICAL to the carriage return, your frame will be cutted. I hope this helps Roberts II, Charles K. wrote: >That's what I thought it was at first, but I tried using a single >character like L and Space and I still saw the same problem. > >If I just send out a terminator the code will see it the first time it >is sent out. But if I send a string it takes several sends of the >terminator before the RX_CMD is set. > >Another strange thing is that there is no set # of times the terminator >character must be sent again. Some times it is only 2 more times >sometimes as many as 20. > > >Charles K Roberts II > > >-----Original Message----- >From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] On Behalf >Of Mcgee, Mark >Sent: Friday, November 19, 2004 11:21 AM >To: 'Microcontroller discussion list - Public.' >Subject: RE: [PIC:] USART Troubles > >Hi I haven't had time to go through your code with a fine tooth combe, >but >I've been writing something similar to this recently myself, although I >am yet >to program the chip and test it in circuit. > >If you are connecting via a PC rather than Linux/UNIX, the end-of-line >terminator is actually a carriage-return followed by Line-feed sequence >(CR-LF >0x0D, 0x0A - unix just has LF IIRC- it's been a few years). So I look >for the >Line-Feed as my line terminator. > >Perhaps this could be your issue? > >Cheers, >Mark > > > >>-----Original Message----- >>From: piclist-bounces@mit.edu >>[mailto:piclist-bounces@mit.edu]On Behalf >>Of Roberts II, Charles K. >>Sent: 19 November 2004 16:05 >>To: Microcontroller discussion list - Public. >>Subject: [PIC:] USART Troubles >> >> >>Hello all >> >>I have a bit of PIC code that reads my USART on a 16F873A. I have a 16 >>byte buffer that I write the incoming bytes into. I am looking for a >>Carraige Return as my terminator. It then sets a bit that calls main >>program to read the buffer. >> >>If I just send the CR the routine will respond immediately, >>if I send a >>string with the CR at the end I must send several CR's to set >>my bit to >>call the main body of the routine. >> >>Here is the code >> >>************************************************************** >>********* >>; >>; RX_INT_HANDLER - handles the received commands on serial com >>; called from inside int. >>; >> >>RX_INT_HANDLER >> NOP >>ser_in btfsc RCSTA,OERR >> goto overerror ;if overflow error... >> btfsc RCSTA,FERR >> goto frameerror ;if framing error... >>uart_ready >> btfss PIR1,RCIF >> goto ser_in ;if not ready, wait... >> ;eventually we get something! >>uart_gotit >> bcf INTCON,GIE ;turn gie off. This is IMPORTANT! >> btfsc INTCON,GIE ;MicroChip recommends this check! >> goto uart_gotit ;!!! GOTCHA !!! without this check >> ;you are not sure gie is cleared >> movf RCREG,W ;recover uart data >> bsf INTCON,GIE ;re-enable interrupts!! >> movwf Temp ;save for later >> MOVLW Rx_Buffer ;Move Address of Rx_Buffer to W >> ADDWF Rx_Num,W ;Add Rx_Num to Rx_Buffer >> >> MOVWF FSR ;Place W (Rx_Buffer + Rx_Num) into FSR >> MOVF Temp,W >> MOVWF INDF >> INCF Rx_Num,F >> >> MOVF Temp,W >> XORLW 0x0D ;0x0D Must use single charchter for >>terminator 11_18_04 >> BTFSS STATUS,Z >> GOTO RX_INT_HANDLER >> >> >> BSF Os_Action,RX_CMD >> return >> >>overerror ;over-run errors are usually >> ;caused by the incoming data >> ;building up in the fifo. >> ;this is often the case when >> ;the program has not read the >> ;uart in a while. >> ;flushing the fifo will >> ;allow normal input to resume. >> ;note that flushing the fifo >> ;also automatically clears >> ;the ferr flag. >> ;pulsing cren resets the oerr flag >> bcf INTCON,GIE ;turn gie off. This is IMPORTANT! >> btfsc INTCON,GIE ;MicroChip recommends this check! >> goto overerror ;!!! GOTCHA !!! without this check >> ;you are not sure gie is cleared! >> >> bcf RCSTA,CREN ;pulse cren off... >> movf RCREG,W ;flush fifo >> movf RCREG,W ; all three elements. >> movf RCREG,W >> bsf RCSTA,CREN ;turn cren back on. >> ;this pulsing of cren >> ;will clear the oerr flag. >> bsf INTCON,GIE ;enable interrupts. >> goto ser_in ;try again... >> >>frameerror ;framing errors are usually >> ;due to wrong baud rate >> ;coming in. >> >> bcf INTCON,GIE ;turn gie off. This is IMPORTANT! >> btfsc INTCON,GIE ;MicroChip recommends this check! >> goto frameerror ;!!! GOTCHA !!! without this check >> ;you are not sure gie is cleared! >> >> movf RCREG,W ;reading rcreg clears ferr flag. >> bsf INTCON,GIE ;enable interrupts. >> goto ser_in ;try again... >> >>Charles K Roberts II >> >> >> >>_______________________________________________ >>http://www.piclist.com PIC/SX FAQ & list archive >>View/change your membership options at >>http://mailman.mit.edu/mailman/listinfo/piclist >> >> >> > >======================================================================== >====== >This message is for the sole use of the intended recipient. If you >received >this message in error please delete it and notify us. If this message >was >misdirected, CSFB does not waive any confidentiality or privilege. CSFB >retains and monitors electronic communications sent through its network. >Instructions transmitted over this system are not binding on CSFB until >they >are confirmed by us. Message transmission is not guaranteed to be >secure. >======================================================================== >====== > >_______________________________________________ >http://www.piclist.com PIC/SX FAQ & list archive >View/change your membership options at >http://mailman.mit.edu/mailman/listinfo/piclist > >_______________________________________________ >http://www.piclist.com PIC/SX FAQ & list archive >View/change your membership options at >http://mailman.mit.edu/mailman/listinfo/piclist > > > _______________________________________________ http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist