Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

What does this instruction mean ?

Status
Not open for further replies.

Electrix

Member
Hi, I'm using a PIC 16F73 for a Temp. Controller.

The delay loop that provides a 12-microsecond timer for the LCD is:

T12us
goto $+1
goto $+1
goto $+1
goto $+1
nop
return

In this subroutine what does the 'goto $+1' mean?? I've checked the code throughly and the $ is not assigned to any address.

Plz help.
 
Electrix said:
Hi, I'm using a PIC 16F73 for a Temp. Controller.

The delay loop that provides a 12-microsecond timer for the LCD is:

T12us
goto $+1
goto $+1
goto $+1
goto $+1
nop
return

In this subroutine what does the 'goto $+1' mean?? I've checked the code throughly and the $ is not assigned to any address.

Plz help.
Ok, first, what is your oscilator frequency? This delay is making 13 empy cycles, therefore if your PIC runs @ 4Mhz, it gives you delay of 13us...

$ stands for actual Program Counter address, therefore Goto $+1 will just jump on the next line (and it will take two instruction cycles to do so). It is used to save space, beacuse Goto $+1 equals two NOP instructions.
 
Jay.slovak said:
Electrix said:
Hi, I'm using a PIC 16F73 for a Temp. Controller.

The delay loop that provides a 12-microsecond timer for the LCD is:

T12us
goto $+1
goto $+1
goto $+1
goto $+1
nop
return

In this subroutine what does the 'goto $+1' mean?? I've checked the code throughly and the $ is not assigned to any address.

Plz help.
Ok, first, what is your oscilator frequency? This delay is making 13 empy cycles, therefore if your PIC runs @ 4Mhz, it gives you delay of 13us...

$ stands for actual Program Counter address, therefore Goto $+1 will just jump on the next line (and it will take two instruction cycles to do so). It is used to save space, beacuse Goto $+1 equals two NOP instructions.
my oscillator freq is 5Mhz..so how does it give 12microseconds ( 13*800n=10.4 u sec..)
 
Electrix said:
Jay.slovak said:
Electrix said:
Hi, I'm using a PIC 16F73 for a Temp. Controller.

The delay loop that provides a 12-microsecond timer for the LCD is:

T12us
goto $+1
goto $+1
goto $+1
goto $+1
nop
return

In this subroutine what does the 'goto $+1' mean?? I've checked the code throughly and the $ is not assigned to any address.

Plz help.
Ok, first, what is your oscilator frequency? This delay is making 13 empy cycles, therefore if your PIC runs @ 4Mhz, it gives you delay of 13us...

$ stands for actual Program Counter address, therefore Goto $+1 will just jump on the next line (and it will take two instruction cycles to do so). It is used to save space, beacuse Goto $+1 equals two NOP instructions.
my oscillator freq is 5Mhz..so how does it give 12microseconds ( 13*800n=10.4 u sec..)
It can't, there has to be a misstake somewhere.

BTW what kind of LCD do you use ? If it is HD447800, try the pooling method instestead of waiting in a loop...
 
maybe it's the return instrn that is totalling the delay time to 12u secs.

I have read a lot of codes and almost all do not consider the return inst in their calculations.. by the way how much time would the return take in my case ??
 
Electrix said:
maybe it's the return instrn that is totalling the delay time to 12u secs.

I have read a lot of codes and almost all do not consider the return inst in their calculations.. by the way how much time would the return take in my case ??
My calculation of 13 cycles is including CALL and RETURN instructions, both take two cycles. :twisted:
 
Jay is right; that routine takes 13 instruction cycles to complete:

Code:
T12us   ; the call to get here takes 2 instructions
goto $+1       ; 2 instr
goto $+1       ; 2 instr
goto $+1       ; 2 instr
goto $+1       ; 2 instr
nop            ; 1 instr
return         ; 2 instr

If the original poster wants a routine that takes 12uS on a 5MHz clock then he just has to add one more goto $+1:
12uS / .8uS per instruction = 15 instructions.

Mike
 
upand_at_them said:
Jay is right; that routine takes 13 instruction cycles to complete:

Code:
T12us   ; the call to get here takes 2 instructions
goto $+1       ; 2 instr
goto $+1       ; 2 instr
goto $+1       ; 2 instr
goto $+1       ; 2 instr
nop            ; 1 instr
return         ; 2 instr

If the original poster wants a routine that takes 12uS on a 5MHz clock then he just has to add one more goto $+1:
12uS / .8uS per instruction = 15 instructions.

Mike
Yep, that works...
But try to implement BUSY Flag checking, to speed things up :wink:
 
Electrix said:
In this subroutine what does the 'goto $+1' mean?? I've checked the code throughly and the $ is not assigned to any address.

It's an 'assembler directive' and is explained in the MPASM helpfile, and as already explained it refers to the current address. It's also VERY useful in loops where you are checking an input pin (using BTFSS or BTFSC), you can use $-1 after the test to loop back - it saves allocating a label.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top