Hello.
I need to generate a series (5000 pulses for example, but it might be 1000 pulses) with shortest duration possible. The code like this:
Code:
HEAD:
PORTB.6=1
PORTB.6=0
GOTO HEAD
do works, but it has an issue - GOTO statement takes more time to execute, then simple port enable-disable, so pause between pulses is longer than pulse itself, which is not welcomed.
Of course, I can write
PORTB.6=1
PORTB.6=0
PORTB.6=1
PORTB.6=0
multiple times, but 5000 times?
Tried it on various MCU's on all of them, GOTO or DO-LOOP or FOR-NEXT or any other looping instruction takes more time. Any ideas how to solve this?
I come to partial solution like this:
Code:
PIKO:
PORTB.6=1
@NOP
PORTB.6=0
GOTO PIKO
In this code, @NOP statement lengthens the pulse itself, so it is equal to width of pause, but of course, overal frequency is reduced.
Currently using 16F1829 @ 32mhz, and I want to avoid usage of 18F or 24F family at all costs.
Bookmarks