Help please with Assembly (PBPro user)


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Jun 2005
    Location
    West Australia
    Posts
    116

    Question Help please with Assembly (PBPro user)

    Hi folks,
    I've steered away from Assembly as long as I could but am stuck with an old Application Note (AN715) that is exactly what I need - problem is the code is only available in the pdf complete with a bunch of other stuff in the listing.

    I copied this across to a text file and laboriously edited out all the line numbers, etc. but can only get the errors down to about 37 (using MPASM 5.03). I don't know anything about Assembly so don't have a clue how to get any further. Long term plans will be to learn this but so far PBP has proven to be everything I need for a long time now.

    Rather than look like a complete idiot contacting Microchip I thought I'd ask the Guru's on the PBP list for some help.

    If anyone can offer some suggestions on removing the last of these errors it would be very welcome. I'm sure this is obvious to the educated but I'm completely in the dark here.

    Kind regards to all members.
    Bill
    Attached Files Attached Files

  2. #2
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    I am not so experienced at using assembly, but with the help of Darrel, I have been able to get two microchip asm examples to work. (Thanks Darrel!!!).

    This example looks a little more straight forward, but then they always look easy, don't they?

    First, you should define your variables. This I have always done outside the asm portion.
    Code:
    ;example:
    T1XHi        VAR byte 
    T1XLo       VAR byte 
    ..................................etc
    
    
    ;When these variable are used inside asm, you add a little "_" on the front of them:
    asm
    ..........  _T1XHi
    ........... _T1XLo
    
    endasm
    Why don't you start with that, and see how many fewer errors you get. Then post your errors here, and I will try to help you.
    Last edited by ScaleRobotics; - 2nd April 2009 at 17:18.

  3. #3
    Join Date
    Jun 2005
    Location
    West Australia
    Posts
    116


    Did you find this post helpful? Yes | No

    Default

    Hi scalerobotics,
    Thanks for the assistance, I'm sure there are a lot of users out there that are interested in this and will learn as well.

    So are you saying instead of trying to assemble the list as I am, use PBP and paste it in between a Asm and Endasm statement, while declaring the variables up front before that? Or do you mean use _T1X, etc, in the listing without PBP?

    Cheers,
    Bill

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Wink The logical way ...

    Hi, WJS

    Rather than look like a complete idiot contacting Microchip I thought I'd ask the Guru's on the PBP list for some help.
    You wouldn't look like an idiot posting your query on Microchip users Forum ... And you could find people having played with this AN before ... Eventually used to asm too, ...

    NOW ... browsing the Parallax site, you could discover ( oh surprise ! ) that they have a Memsic 2125 accelerometer , with Application examples AND BS2 Code ...

    Knowing the 2125 works in the PWM way like the adsl 202, AND BS2 code, which is PbP COMPATIBLE ...

    Why are you still sllepingly staring at that post ....

    Hurry up !!! ... LOL

    Alain
    Last edited by Acetronics2; - 3rd April 2009 at 10:24.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by wjsmarine View Post
    So are you saying instead of trying to assemble the list as I am, use PBP and paste it in between a Asm and Endasm statement, while declaring the variables up front before that? Or do you mean use _T1X, etc, in the listing without PBP?
    Hello Bill,

    From your previous post, it sounded like you were happy with the speed of programming with pbp, and that it could do almost everything you wanted. We should be able to get your tilt.asm working with pbp as an include file, which would let you add you own code in pbp and get the tilt sensor doing something useful.

    To start with, you will need to define the variables. (of course, you will have to start with defining the osc, your ports, etc, just as you always do). I define the variables inside pbp, which lets them be used within the pbp, as well as the asm portions of your code. When you do this:

    T1XHi VAR byte
    T1XLo VAR byte

    inside your asm, the variables need to look like this:
    asm
    movwf _T1XHi
    movf _T1XLo, W
    endasm

    You can look at my first conversion as an example. This assembly used object code, and yours does not. That's why I think it will be a little easier. Check out:
    http://www.picbasic.co.uk/forum/showthread.php?t=7502


    Your code looks interesting. Would be glad to help if you decide to proceed.

    Walter
    Last edited by ScaleRobotics; - 3rd April 2009 at 16:34.

  6. #6
    Join Date
    Jun 2005
    Location
    West Australia
    Posts
    116


    Did you find this post helpful? Yes | No

    Default

    Hi Walter,

    Thanks for the help. I'm going to have to work on this in the background unfortunately because of a sudden unexpected pile of work which has just descended (meaning from Above, if you know what I mean!) onto me. I'll get back to you as soon as I can clear some of the work and have some news. Thanks also for the link to your previous effort, very informative.

    Thanks Acetronics for the pointer - I'll take a look but I think it best for my education to persist with the asm challenge as no doubt there will be other times when I will need to do something similar with asm code I come across.

    Kind regards to all.
    Bill

  7. #7
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    I looked a little more at the assembly code you attached to your post. One drawback, it uses LCD code that is written for 4 mhz crystal which makes it a bit less flexible. This could be edited out and more code written for pbp, to be flexible for use with different pics. By the time you do that, maybe Alain is right, better to use code that is written in picbasic.

    I looked at the parallax code, like Alain suggested. They are using a lookup table with a pulsin command. This could be done pretty easily. If you want to make it more exciting, you could use an tan-1 or arctan function. Oh, but picbasic does not have an arctan function you might say.... True, but Darrel helped me get a atan2(y,x) function working, and atan2(y,1) is the same as the tan-1 or arctan function!

    What am I talking about?
    Well, I did a few searches on angle tilt and got to Freescale Semiconductors AN3461
    http://www.freescale.com/files/senso...ote/AN3461.pdf

    And they mention using the arctan function to determine the angle:

    theta = tan-1 (Ax/Az) and I believe that angle of Y = tan-1(Ay/Az)

    A lookup table for the 10 bit a/d converter would be a bit long. And we can have resolution of about .3 degrees with a 10 bit tilt sensor value. (I know your tilt sensor does not work on A/D converter, but rather pulse width, but you could still use this formula).

    Here is the atan2 code:
    http://www.picbasic.co.uk/forum/showthread.php?t=10528

    I will try to show an example in the next couple days.

Similar Threads

  1. Adding PBPro code to an ASM file - how to?
    By wjsmarine in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 9th January 2010, 18:49
  2. Picbasic Pro Demo assembly errors
    By mikeRho in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 2nd January 2008, 06:41
  3. Assembly Guru : Question
    By Archangel in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 20th May 2007, 03:51
  4. from assembly to basic
    By shantanu in forum Off Topic
    Replies: 4
    Last Post: - 1st February 2007, 14:50
  5. How do you do this in Assembly
    By ice in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 10th May 2005, 06:47

Members who have read this thread : 1

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