RS232 communications issue


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Arrow And ...

    GPIO.5 is still in Analog mode.
    Code:
    ANSEL  = %00111011
    And you have both SERIN2 and SEROUT2 on the same Pin GPIO.2.
    <br>
    DT

  2. #2
    Join Date
    Dec 2009
    Posts
    4


    Did you find this post helpful? Yes | No

    Default RS232 communications

    Quote Originally Posted by Darrel Taylor View Post
    GPIO.5 is still in Analog mode.
    Code:
    ANSEL  = %00111011
    And you have both SERIN2 and SEROUT2 on the same Pin GPIO.2.
    <br>
    Actually that is on purpose, there is another processor sending the request and then the 12F683 answers the request either by turning off the voltage regulator or sending the ADC results back. I only had a limited number of ports available on the other processor and it is located remotely from the 12F683.

  3. #3
    Join Date
    Dec 2009
    Posts
    4


    Did you find this post helpful? Yes | No

    Default things to try out tonight...

    Thanks for the ideas! I'll be sure to try them out tonight and get back with the results later.

  4. #4
    Join Date
    Dec 2009
    Posts
    4


    Did you find this post helpful? Yes | No

    Default It works!

    Thank you very much! Just wanted to let everyone know that the solutions presented work great. I did find another issue with the processor that was putting out the RS232 to the 12F683 (incorrect clock freq which threw the timing out the door). The real key to the problem I was having was declaring the VAR value as a WORD and not BYTE - goes to show that you shouldn't take for granted even the little simple things.

    I thought I'd post the final version of the code incase someone else needs help with something like this:
    Code:
    @ DEVICE PIC12F683, MCLR_OFF, INTRC_OSC_NOCLKOUT, WDT_ON, BOD_OFF
    @ DEVICE PWRT_ON, FCMEN_OFF, IESO_OFF, PROTECT_OFF
    
    DEFINE ADC_BITS       10
    DEFINE ADC_CLOCK      3
    DEFINE ADC_SAMPLEUS   200
    
    ANSEL  = %00111011
    ADCON0 = %10000001
    TRISIO = %0001111
    OSCCON = %01100000
    CMCON0 = %00000111
    INTCON.7 = 0
    INTCON.3 = 1
    
    RESULT  VAR word[3]
    value   var byte
    holding var word
    i       var byte
    
    MAIN:
         output GPIO.5
         GPIO.5 = 1
         Goto Main1
    
    Main1:
         SERIN2 GPIO.2, 396, [WAIT("A"), value]
         if value = 1 then
           GPIO.5 = 0
         else
           if value = 2 then
             gosub GETADC
             gosub display1
           endif
         endif
         goto Main1
         end
         
    display1:
         serout2 GPIO.2, 396, 10, [dec result[0], 13]
         serout2 GPIO.2, 396, 10, [dec result[1], 13]
         serout2 GPIO.2, 396, 10, [dec result[2], 13]
         return     
         end
         
    GETADC:
         'average ADC over 10 cycles
         holding = 0
         for i = 1 to 10
           adcin 0, result[2]
           holding = holding + result[2]
           pause 10
         next i
         holding = holding/10
         result[2] = holding
         
         holding = 0
         for i = 1 to 10
           adcin 1, result[1]
           holding = holding + result[1]
           pause 10
         next i
         holding = holding/10
         result[1] = holding
    
         holding = 0
         for i = 1 to 10
           adcin 3, result[0]
           holding = holding + result[0]
           pause 10
         next i
         holding = holding/10
         result[0] = holding   
         return
         end
    end
    Next job is to figure out the settings to place the processor in sleep with a wake-up on interrupt from GPIO.2 when a serial input is recieved. I need to do some reading in the datasheet and search previous posts first. Its nice to know that there are some knowledgeable people out there if I run into problems!

    Bob

Similar Threads

  1. UART vs software RS232
    By Michael in forum mel PIC BASIC Pro
    Replies: 27
    Last Post: - 5th September 2008, 18:27
  2. PIC18F4680 to PC via MAX232 (RS232 serial) no output
    By opticsteam1 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 14th April 2008, 20:39
  3. 18F1320 ... Strange Memory
    By Acetronics2 in forum mel PIC BASIC Pro
    Replies: 43
    Last Post: - 9th April 2006, 09:55
  4. PIC Basic Pro <-> HP-IL communications
    By swr999 in forum Serial
    Replies: 0
    Last Post: - 6th March 2006, 18:30
  5. Infrared Communications over RS232 UART or with B0 interupt
    By modifyit in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 9th December 2005, 19:17

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