Calculated pauses don't work?

ocwo92

New Member
I'm somewhat stumped with the following piece of code. I want to fire a series of flashes with a predetermined delay inbetween. But somehow I can't get the delay code to work. Here's what I really wanted to code:

Code:
[1]		pause_length = flash_delay * 100 
[2]		for j = 1 to number_of_flashes
[3]			pulsout 1, 100 ' 1 ms pulse
[4]			pause pause_length
[5]		next j
where flash_delay is guaranteed to always be a number between 1 and 99, thus making the pause well below the maximum of 65535. For example, with a value of flash_delay = 40, the delay should be four seconds.

However, the pause doesn't appear to be executed, or maybe flash_delay isn't being multiplied with 100, or whatever happens.

The following code works, however, where instead of using the calculated pause_length in line 4 above, I loop a number of 100 ms pauses in lines 3 through 5:

Code:
[1]		for j = 1 to number_of_flashes
[2]			pulsout 1, 100 ' 1 ms pulse
[3]			for k = 1 to flash_delay
[4]				pause 100
[5]			next k
[6]		next j
I suspect that pause may require an immediate operand and doesn't support register-direct addressing, but I can't gather this information from the manual.

Can anyone explain to me what I'm doing wrong in the first version?
 
Last edited:

inglewoodpete

Senior Member
You have not included your definitions for the variables. Perhaps you have used a byte variable for pause_length (maximum value = 255)
 

ocwo92

New Member
You have not included your definitions for the variables. Perhaps you have used a byte variable for pause_length (maximum value = 255)
You're right. I'm still new to the 08M and didn't realize that b0, b1, etc. referred to byte variables. I simply assumed this was what the registers were called. Using a word register instead solved the problem. Thanks!
 

John West

Senior Member
Without the rest of your code I find it hard to follow.

---
EDIT: Good going, Pete. That was what I was thinking as well.
 
Last edited:

hippy

Technical Support
Staff member
For example, with a value of pause_length = 40, the delay should be four seconds.
That confused me at first as pause_length = 40 would be a 40ms delay. You obviously meant flash_delay=40, giving pause_length = 4000, four seconds.
 
Top