Proton PICBASIC vs MeLabs PICBASIC


Closed Thread
Results 1 to 23 of 23

Hybrid View

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

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

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

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

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by dhouston View Post
    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.
    Hi,

    Full-duplex software UART is not possible or possible only if the baud rate
    is very low and interrupts are used. (Software UARTs use bit-banging).

    Soft Uart for P12 by Warren Schroeder:

    If you look at the code you will see that RX uses an interrupt and that in
    the SUB TX_19200 interrupts are disabled. This means that while
    you are sending data you cannot receive data at the same time. (Not Full-duplex).

    Best regards,

    Luciano
    Last edited by Luciano; - 9th January 2008 at 18:31.

  6. #6
    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
    Full-duplex software UART is not possible or possible only if the baud rate is very low and interrupts are used. (Software UARTs use bit-banging).
    It could be done if you send and receive in the interrupt. Set it to interrupt at 2*baud, and alternate Tx/Rx. At 9600 baud, with 19200kHz interrupt rate on a 20MHz crystal, you get 260 code cycles to perform each...that should be more than enough, and cycles left over for other regular code. You might even get close to that rate with a 4MHz crystal if you are thrifty with your code.

    Or, in the interrupt do the Tx send first, then all Rx work, then Tx setup for the next bit, without alternating, so the "Tx send" portion is actually very short and always the same length. This might be more efficient, but maybe a little more coding.

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


    Did you find this post helpful? Yes | No

    Default MikroE Basic

    Luciano -

    I will try that code. The last time I tried the Soft_Uart_Read was blocking. I see v6.0.0.0 has a heap of changes.

    I just found it frustrating when trying to convert a simple working PBP program to MikroE Basic. What better way to learn a new language than to convert code you already know and understand in PBP.

    I'll stick with PBP for now until I need ethernet or have some time to do some test projects.....

    bill.

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

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

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


    Did you find this post helpful? Yes | No

    Default

    One nice thing about Proton+ is in the forum, Les the compiler author occasionally posts misc. PDS code. (In addition to helping out on the forum when needed.) For instance, he's posted a full Space Invaders game that works with the Crownhill development board... which is modeled in the VSM simulator so you can play it right on your PC screen (or the actual development board).

    He's also posted code to use as a serial buffer for the hardware usart, so it will receive data in the background, and fill it in when you get around to using a hserin command. More examples are speech decompression routines, and a full .wav file player design with CF FAT and audio out routines.

    These are just a few examples. Some of them can easily be ported to PBP; others may take some work.

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