help me to understand 3 lines of code ( concerning assembly and PBP programming)


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2009
    Posts
    30

    Default help me to understand 3 lines of code ( concerning assembly and PBP programming)

    Hello every one

    i m new to this forum and i feel sad to start posting questions instead of answers!! but you guyz are so smart and i learned alot from you.

    i want to ask about 3 lines in an HID code by steve http://www.picbasic.co.uk/forum/showthread.php?t=5418

    i downloaded the code and created a vb2008 interface and everything is working great.

    still i want to understand the code properly. the first one

    Code:
    Reload_TMR0 macro
        ;   Use to stop, reload, clear overflow flag and restart TMR0
        BCF     _TMR0ON         ; stop timer
        MOVE?CW d'65000',TMR0L  ; reload for timebase ~100uSec
        BCF     _TMR0IF         ; clear overflow flag
        BSF     _TMR0ON         ; start timer
        ENDM
    
    SendUSB macro array
        ;   Use to Copy an specific array to USBBufferOut AND send it
        ;   to USB bus
        variable i=0
        while i<8
            MOVE?BB (array+i),(_USBBufferOut+i)
    i+=1
        endw
        L?CALL _DoUSBOut
        endm
    what doest those words mean? are they instructions ? i searched for hour to understand what does mov?cw mean. found nothing !!
    mov?cw
    mov?bb
    l?call
    ???????????????????????????

    i also had to comment out those lines
    Code:
      '   USB module
            '   ----------
        UCFG    var byte EXT        ' include UCFG register... Yeah Melabs didn't :o(
        ucfg    =   %00010100       ' enable internal USB pull-up, Full speed USB
    because when i have them in the code, the PC doesnt see my pic. it doesnt even give a "not recongnized" msg. but when i comment them out , everything is ok again.

    i looked to 18f2550 datasheet and found that ucfg controls the speed of usb bus.

    i dont know if the problem caused by my usb ( is it low speed ? ) ?


    finally, excuse me for not being able to write english properly. but it is not my original language.

    thx all in advance

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


    Did you find this post helpful? Yes | No

    Default

    This should get you started. Let us know if you have more questions after reading about them.

    http://www.picbasic.co.uk/forum/show...9219#post89219

    L?CALL _DoUSBOut ; is a call to subroutine _DoUSBOut

    For your last question,
    It looks like version 2.60a has included the register UCFG, so you should hopefully be ok adding the second line only,

    UCFG = %00010100

    From the data sheet:
    Bit 4 means
    1 = On-chip pull-up enabled (pull-up on D+ with FSEN = 1 or D- with FSEN = 0)

    Bit 2 means :
    1
    = Full-speed device: controls transceiver edge rates; requires input clock at 48 MHz
    Last edited by ScaleRobotics; - 29th October 2010 at 01:14. Reason: UCFG part
    http://www.scalerobotics.com

  3. #3
    Join Date
    Oct 2009
    Posts
    30


    Did you find this post helpful? Yes | No

    Default

    thanks alot

    thats what i was looking for. i did understand what darrel wrote.

    so is it right to say that using
    Code:
    call
    instead of
    Code:
    L?call
    will do the job ? but it is more simple for the compiler to deal with
    Code:
    L?call
    more than
    Code:
    call
    ?

    and we can use assembler instructions combinations to do somthing but using
    Code:
    mov?cw
    will make it easier .

    do i get it right ?

    and last thing, those are macros right ? where do i find them defined ? because i searched inside the mac file of my project but i didnt find them all.

    thx again for replying. maybe i didnt get the whole idea but believe me i feel far better now because i do know what ?cw or ?BB means!!

    learnt alot today !!

    thaaaaaaaaaaanx

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


    Did you find this post helpful? Yes | No

    Default

    If you are just starting out, I think it is much better to ignore the macro's, and start with the basics. USB would be pretty far down my list. Just learn the basic commands that are listed in the manual. Once you have a firm grasp of those, then move on to higher levels.

    I would stick to goto and gosub for now. If you mix assembly in (more advanced knowledge required) you can use call to get to those subroutines. But again, that's further down the learning list.

    If you want to learn about macro's, one of the places to look at them are in the .mac files, like pbppic18.mac etc. They really are not defined anywhere, but there are a fair amount of comments in the files.
    Last edited by ScaleRobotics; - 29th October 2010 at 14:16.
    http://www.scalerobotics.com

  5. #5
    Join Date
    Oct 2009
    Posts
    30


    Did you find this post helpful? Yes | No

    Default

    i know all the basics of programming. i worked on pic for more than tow years and i developed some good project. i do know how to write programs with assembly and basic.

    however, sometimes i see something new to me ( alot of things, though i m not beginner!!, but still learning !! ) and i love to know how it works. i dont like to use templates before i know how they work.

    today i saw that mov?cw , and i didnt see it before. so i asked to know what does it mean

    thx scalerobotics for helping me.

    bw

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


    Did you find this post helpful? Yes | No

    Default

    My mistake, sorry.

    I just edited my prior response. If you want to learn about macro's, one of the places to look at them are in the .mac files, like pbppic18.mac etc. They really are not defined anywhere, but there are a fair amount of comments in the files.
    Last edited by ScaleRobotics; - 29th October 2010 at 14:16.
    http://www.scalerobotics.com

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


    Did you find this post helpful? Yes | No

    Default Macros

    Last edited by ScaleRobotics; - 29th October 2010 at 13:55.
    http://www.scalerobotics.com

  8. #8
    Join Date
    Oct 2009
    Posts
    30


    Did you find this post helpful? Yes | No

    Default awesome

    i m reading what you have posted. specially the assembler manual, i find it very useful

    thx for the links

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