Proton PICBASIC vs MeLabs PICBASIC


Closed Thread
Results 1 to 23 of 23

Hybrid View

  1. #1
    Join Date
    Sep 2007
    Location
    USA, CA
    Posts
    271


    Did you find this post helpful? Yes | No

    Default

    For those who don't know, Swordfish was written by the same guy who wrote MicroCode Studio (PBP IDE) and also the IDE for Proton.

  2. #2
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    mikroBasic for PIC is another procedural basic. It's very advanced in some areas (e.g. handling interrupts), less so in others. It has a ton of libraries although they tend to be 18F oriented. It's worth investigating if you're trying to decide on a PIC development language. It costs less than PBP and you don't need a license for apps that are smaller than 2K.

  3. #3
    Join Date
    Feb 2003
    Location
    Sydney, Australia
    Posts
    126


    Did you find this post helpful? Yes | No

    Default

    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...

    But on the other hand it does support GLCD, Ethernet parts and CF or SD Cards out of the box.

    bill

  4. #4
    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.

  5. #5
    Join Date
    Dec 2005
    Posts
    1,073


    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...
    But writing an interrupt routine is a piece of cake and examples are easy to find - I think they are even included.

  6. #6
    Join Date
    Sep 2007
    Location
    USA, CA
    Posts
    271


    Did you find this post helpful? Yes | No

    Default

    I don't use Mikrobasic, but here is an easy way to do it without interrupts...just translate the code to proper syntax. (And set the symbols of cTxReg etc. to the appropriate values. Leading characters are: c=constant, b=byte.)

    bDelayTime = 0
    CheckForData:
    if cTxReg = cDataWaiting then 'check hardware Tx register for incoming data.
    serin = bSerialDataIn 'get data...
    goto SerialDataReceived
    else 'no data waiting...
    pause 1 'wait 1ms...change to match your baud rate, since some speed may overwrite
    bDelayTime = bDelayTime + 1
    if bDelayTime = cMaxWaitTime then
    goto NoSerialDataReceived
    endif
    goto CheckForData
    endif

  7. #7
    Join Date
    Sep 2007
    Location
    USA, CA
    Posts
    271


    Did you find this post helpful? Yes | No

    Default

    For those wanting to do it with interrupts, do a quick search for "buffer" on the Proton forum. ( http://www.picbasic.org/forum/ ) Les, the PDS author, wrote a subroutine for 18F's to buffer all incoming serial data. It should be possible (given enough ingenuity) to convert it to PBP or Mikrobasic.

  8. #8
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    For those wanting to do it with interrupts, download the Soft Uart for P12 by Warren Schroeder project from http://www.mikroe.com/en/projects/

    It's an excellent tutorial as well as an interrupt driven full-duplex software UART. The code is quite simple and easy to follow.

  9. #9
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by tenaja View Post
    I don't use Mikrobasic, but here is an easy way to do it without interrupts...just translate the code to proper syntax. (And set the symbols of cTxReg etc. to the appropriate values. Leading characters are: c=constant, b=byte.)

    bDelayTime = 0
    CheckForData:
    if cTxReg = cDataWaiting then 'check hardware Tx register for incoming data.
    serin = bSerialDataIn 'get data...
    goto SerialDataReceived
    else 'no data waiting...
    pause 1 'wait 1ms...change to match your baud rate, since some speed may overwrite
    bDelayTime = bDelayTime + 1
    if bDelayTime = cMaxWaitTime then
    goto NoSerialDataReceived
    endif
    goto CheckForData
    endif
    Hi,

    Your code does not work with software UARTs.

    Software UART routines use bit-banging techniques and can use almost any I/O pin
    of the microcontroller. Software UARTs have big limitations and if the microcontroller has
    hardware UARTs just use them!

    Best regards,

    Luciano

  10. #10
    Join Date
    Sep 2007
    Location
    USA, CA
    Posts
    271


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Luciano View Post
    Your code does not work with software UARTs.
    This is absolutely true.

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