Proton PICBASIC vs MeLabs PICBASIC


Results 1 to 23 of 23

Threaded View

  1. #10
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by bcd View Post
    I have a copy of MikroBasic, but find it frustrating that it does
    not have equivalents to SerIn2 command with time-outs if there is no data. So for
    any serial you need to write an interrupt routine otherwise the serial receive is
    a blocking command...
    Hi Bill,

    I have never used the MikroBasic compiler but after a quick
    look at the PDF manual I have a solution for your software UART
    timeout problem.

    Best regards,

    Luciano


    From page 257 of MikroBasic for Pic.
    (This is the original sample code).
    Code:
    ' Here's a loop which holds until data is received:
    
    error = 1
    
    do
      data = Soft_Uart_Read(error)
    loop until error = 0
    Here is a version with timeout using BREAK to exit the Do loop:
    Code:
    ' Here's a loop which holds until data is received
    ' or the timeout value has reached 10000. 
    
    Dim MyTimeOutCounter as longint
    Dim MyError as byte
    Dim MyData as byte
    ....
    ....
    
    MyError = 1
    MyTimeOutCounter = 0
    
    Do
    
      MyData = Soft_Uart_Read(MyError)
      
      MyTimeOutCounter = MyTimeOutCounter + 1 ' increment our timeout counter
      
      If MyTimeOutCounter = 10000 Then ' you will have to adjust this value
         Break  'Exit the Do Loop
      End if
    
    Loop until MyError = 0
    
    If MyError = 0 Then ' Optional IF 
      ' Serial transfer was successful
    Else
      ' Timeout occured
    Endif
    Last edited by Luciano; - 9th January 2008 at 10:58.

Similar Threads

  1. PICBasic Pro vs. Proton Dev System
    By hjsong in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 6th February 2007, 04:17
  2. PICBasic Pro vs Proton PICBasic
    By CosMecc in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 3rd November 2006, 16:11
  3. help me Proton PICBASIC version compl
    By samirouf in forum mel PIC BASIC
    Replies: 2
    Last Post: - 1st May 2005, 19:25
  4. Question for all that use MELABS PICBASIC PRO
    By oskuro in forum Off Topic
    Replies: 2
    Last Post: - 24th March 2005, 17:15
  5. Proton development board with Picbasic
    By pjsmith in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 25th July 2004, 22:19

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