PDA

View Full Version : help me to understand 3 lines of code ( concerning assembly and PBP programming)



Ahmadabuomar
- 29th October 2010, 00:29
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


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

' 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

ScaleRobotics
- 29th October 2010, 00:52
This should get you started. Let us know if you have more questions after reading about them.

http://www.picbasic.co.uk/forum/showthread.php?t=13195&p=89219#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

Ahmadabuomar
- 29th October 2010, 01:53
thanks alot

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

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

and we can use assembler instructions combinations to do somthing but using
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

ScaleRobotics
- 29th October 2010, 02:41
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.

Ahmadabuomar
- 29th October 2010, 02:51
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

ScaleRobotics
- 29th October 2010, 03:00
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.

ScaleRobotics
- 29th October 2010, 13:52
Here are some more sources of info about macros:

http://www.gooligum.com.au/tutorials/midrange/PIC_Mid_A_5.pdf
http://www.rentron.com/Myke8.htm
http://ww1.microchip.com/downloads/en/DeviceDoc/33014K.pdf Only 3 pages though (in Chapt 7)

Ahmadabuomar
- 29th October 2010, 14:30
i m reading what you have posted. specially the assembler manual, i find it very useful

:o thx for the links