Access array in PBP and .asm


+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2004
    Posts
    61

    Default Access array in PBP and .asm

    Hi Folks,

    I'm working on a project where I'm simultaneously receiving, manipulating, and transmitting serial data. This data comes and goes in 64-byte chunks.

    I'd like to set up an interrupt routine in assembly language to receive the data, and then use PBP to handle the rest of the functionality.

    Serial reception will be through the chip's UART (an 18F part) and transmission will be done in software. The incoming and outgoing baud rates are wildly different, so I can't just use the TX side of the same UART.

    Nor can I receive a packet, reset the UART to a different baud rate and then retransmit, as I'll miss critical incoming data.

    Therefore, the transmit and receive threads need to run concurrently and independently.

    Here's the question:

    If I define an array in PBP like this:

    DataIN VAR byte[64]

    how do I access it from within the .asm routine?

    I'm sure it's not difficult, but I can't quite wrap my brain around it.

    I know that a single PBP variable Foo can be accessed as _Foo in assembly. But how does it work with an array?

    JEC

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405

    Default

    Already done for you http://www.melabs.com/resources/samp...p/serbufAx.bas

    Just change the buffer size & tweak to your specs.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    Nov 2004
    Posts
    61

    Default

    Quote Originally Posted by Bruce View Post
    Already done for you http://www.melabs.com/resources/samp...p/serbufAx.bas

    Just change the buffer size & tweak to your specs.
    Don't know how I missed that in my searching.

    Many thanks, Bruce. That looks perfect.

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

    Default

    Hi John,

    One problem that you will probably have is in trying to send serial data using SEROUT(2).

    Those commands are timed by software, which will be continuously interrupted by the USART RX handler, which throws off the baud rate.

    A possible solution can be found here ...
    http://www.picbasic.co.uk/forum/showthread.php?p=53931

    It uses a Timer as the baud rate generator, which overcomes the software timing problems.

    HTH,
    DT

  5. #5
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107

    Default

    Could you possibly use a PIC with two hardware UARTS? That would make things *so* much easier.
    Charles Linquist

  6. #6
    Join Date
    Nov 2004
    Posts
    61

    Default

    Quote Originally Posted by Charles Linquis View Post
    Could you possibly use a PIC with two hardware UARTS? That would make things *so* much easier.
    Actually, that's the part I didn't mention. I'm looking at the 18F6310, which appears to be only a couple dollars. Unless I've missed something, that's the smallest of the 18Fs with two ports, and it comes in a 64-TQFP package.

    It has two hardware ports and two separate interrupt generators.

    However, the ability to receive data into an array in the .asm routine is still very desirable. I can do my array massaging in the main program, then dump it out the door.

    Darrel's link above describes some neat tricks too.

    The depth of knowledge & willingness to share on this board is always amazing. Thanks to all who have taken a moment to reply.

Similar Threads

  1. ASM code
    By Bill Legge in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 1st March 2010, 23:55
  2. PBP 2.6/MPLab 8.33 ASM "COD" error message
    By reddog24 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 3rd December 2009, 20:09
  3. Tracing & Stepping: PBP & MPLAB
    By chicowoodhill in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 7th September 2008, 01:23

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts