RS-232 confusion


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,722


    Did you find this post helpful? Yes | No

    Default Re: RS-232 confusion

    this should get close to it


    Code:
    define OSC 48
    some vars
    bits var byte[13] ' an array to hold the 100 bits
    I_data var PORTB.2    'lets call this the input
    bit_count var byte
     
     
    'a subroutine
    bit_read:
    t4con=0   ' timer off
    tmr4=0   ' clear timer
    bit_count = 0
    while ( i_data) : wend  ' wait here till input goes idle
    while ( ! i_data) : wend 'wait here till input goes high  to sync up
    t4con=$7e  '256:1// count of 45 or so = 1mS
    while ( i_data) : wend  ' wait here till input goes low
    t4con=0   ' timer off
    if (tmr4 >43 ) and (tmr4 < 47) then goto start_ok '  bit of latitude might need more
    goto bit_read
    start_ok:
    while bit_count < 100
    tmr4=0   ' clear timer 
    pir3.3=0  'clear timer overflow flag
    while ( ! i_data) : wend 'wait here till input goes high 
    t4con=6     ;  prescale 16 timer on
    while ( i_data) : wend  ' wait here till input goes low
    t4con=0   ' timer off
     if  pir3.3 then bits.0[bit_count]=1  ;  ontime > 340 uS  
    else
      bits.0[bit_count]=0 '  the ontime < 340 uS 
    endif
     bit_count=bit_count+1
    wend
           
     return

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: RS-232 confusion

    As far as the IDLE high or IDLE low state, looking at the signal with a scope, where is the bus signal level when NO data is being sent? I would imagine it to be high, as most single wire communications use a passive sourced current to stimulate the bus wire (usually a resistor). That way there can be more than 1 device listening as well as more than 1 device able to answer a request. This is done by pulling the line LOW thru an open collector transistor or N channel fet.
    Dave Purola,
    N8NTA
    EN82fn

Similar Threads

  1. Arbitration of 232 signals
    By blmcali in forum Serial
    Replies: 1
    Last Post: - 13th July 2012, 04:06
  2. PIC18F2450 Rs-232
    By PlantBob in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 4th February 2011, 00:14
  3. PIC18F2450 Rs-232
    By PlantBob in forum General
    Replies: 3
    Last Post: - 17th January 2011, 18:58
  4. polling information in rs-232
    By Tondunard in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 12th February 2008, 12:32
  5. ethernet to rs-232
    By maus in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 18th April 2006, 17:44

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