Auto Downloads


Results 1 to 13 of 13

Threaded View

  1. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    If you have control over the PC application, then have it ping the data logger (sending an occasional byte) until the logger responds.

    On the PIC side, simply test RCIF on occasion to determine if the PC has been connected, the ping byte has been received, and the RCREG holds something.

    The USART can handle all this in the background, and your main code can do whatever until the PC is connected.

    Code:
    Y       VAR byte    ' Inbound data recovered from RCREG
    RCIF    VAR PIR1.5  ' USART received character interrupt flag bit
    CREN    VAR RCSTA.4 ' USART continuous receive enable bit
    OERR    VAR RCSTA.1 ' USART over-run bit
    
    INTCON  = 0      ' Disable interrupts (just using flags)
    ADCON1 = 7      ' A/D off
    
    TRISB.0 = 0     ' Set RB0 to output
    PORTB.0 = 0     ' LED off (indicates data was in RCREG)
       
    Main:
        IF RCIF THEN Have_Data ' If RCIF=1 there's data in RCREG
        HIGH 1          ' so jump to Have_Data and send your EEPROM
        PAUSE 1000      ' contents
        LOW 1
        PAUSE 1000      ' Long pauses show how RCREG receives data
        GOTO Main       ' in the background
            
    Have_Data:          ' Send your EEPROM data here
        PORTB.0 = PORTB.0 ^ 1 ' Toggle RB0 to indicate data rcvd
        WHILE RCIF            ' Empty RCREG by reading it
         Y = RCREG
        WEND
        ' If OERR = 1 then the over-run bit is set and we need to clear it
        ' to re-enable receive. If not, then carry on
        IF !OERR THEN  Main  ' If no over-run condition, return to Main
        CREN = 0             ' Over-run condition. Disable receive
        CREN = 1             ' Re-enable & clear OERR flag
        GOTO Main
    Last edited by Bruce; - 23rd September 2004 at 18:55.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

  1. How powering PIC in auto ?
    By fratello in forum Schematics
    Replies: 19
    Last Post: - 19th October 2009, 07:35
  2. auto recloser ELCB
    By badbaik in forum mel PIC BASIC
    Replies: 5
    Last Post: - 5th February 2009, 13:54
  3. AUTO baud rate detection FOR UART connection to PC
    By mike20200 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd September 2007, 00:56
  4. Auto Baud Rate Detection
    By mytekcontrols in forum Serial
    Replies: 10
    Last Post: - 31st October 2005, 02:17
  5. Modem Auto Answer-Hanging for 1 min...
    By Ioannis in forum mel PIC BASIC Pro
    Replies: 21
    Last Post: - 22nd August 2005, 09:38

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts