Even if code is like this:
the "goto" occupies much more time. Is there a way to shorten it?Code:HEAD: PORTA.2=1 PORTA.2=0 GOTO HEAD
Even if code is like this:
the "goto" occupies much more time. Is there a way to shorten it?Code:HEAD: PORTA.2=1 PORTA.2=0 GOTO HEAD
No, there's not way to shorten the execution time (in instruction cycles that is) of a GOTO. What you can do is to "lengthen" the time of the other instructions.
Obviously this will also change the frequency.Code:Head: PortA.2 = 1 @ NOP ' Two nops to compensate for the GOTO @ NOP PortA.2 = 0 GOTO Head
/Henrik.
How about if you toggle pin in loop?
Code:HEAD: TOGGLE PORTA.2 GOTO HEAD
I don't want to "lengthen" time, because it significantly lowers the frequency, from about 1mhz to 200khz, which is bad. I've found a partial workaround - I've inserted
16 times, so now having about 90% duty cycle, which is ok.Code:PORTA.2=1 PORTA.2=0 PORTA.4=1 PORTA.4=0
But, is there a way to fix this otherwise?
Try 18 series PIC, or 24 series?
Have you considered doing this in assembly??
Dwight
These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.
It's same thing in ASM.
ASM
tavukaASM:
BSF PORTA,2
BCF PORTAM2
BSF PORTA,4
BCF PORTA,4
GOTO tavukaASM
ENDASM
That is ASM code equivalent of his PBP code.
Still same situation....
Last edited by pedja089; - 3rd February 2015 at 21:09.
Would it be easier to do this with PWM module? With 32MHz you can reach 4MHz output frequency and accurate duty cycle.
I think these PIC's have just one PWM module. If that is not enough, then select other which have more PWM outputs.
At least, trials can be run with your current PIC's.
Last edited by Gusse; - 3rd February 2015 at 21:50.
Bookmarks