2020/10/30 06:45:33
microp
Hello, I have a problem on my DSPIC33EP32MC202.
I have set the clock oscillator and PLL to have 140MHz oscillator. 70 MHz instruction (~140ns).
I have set the output clock divided by 16. With my oscillo, I'm measuring 8,75 MHz, so the oscillator fréquency is OK.
But if I make a loop like that :
bset PORTA,#0
nop
nop
nop
bclr PORTA,#0
nop
nop
nop
............etc (no goto)
I'm measuring ~136ns
 
If I make a loop like that :
loop: bset PORTA,#0
nop
nop
nop
bclr PORTA,#0
nop
goto loop
I'm measuring 163ns
 
And if I make a loop like that :
loop1: bset PORTA,#0
nop
goto loop2
loop2: bclr PORTA,#0
nop
goto loop1
I'm measuring 190ns
 
All the loop take, normally, 8 instruction's cycles :
first : 1+1+1+1+1+1+1+1
second : 1+1+1+1+1+1+2
third : 1+1+2+1+1+2
 
If I suppose NOP and BSET or BCLR are 1 cycle instruction, the GOTO take 3,5 cycles !!!
 
I'm programming in ASM30.
 
A person could explain me please ?
2020/10/30 09:09:02
dan1138
microp
I have a problem on my DSPIC33EP32MC202.
 
...
 
All the loop take, normally, 8 instruction's cycles :
first : 1+1+1+1+1+1+1+1
second : 1+1+1+1+1+1+2
third : 1+1+2+1+1+2
 
If I suppose NOP and BSET or BCLR are 1 cycle instruction, the GOTO take 3,5 cycles !!!
 
A person could explain me please ?



You are using the wrong number of instruction cycles per opcode plus bit set and clear opcodes take 2 cycles for non-CPU registers like the PORTA or LATA registers.

 

Attached Image(s)

2020/10/30 09:36:29
NorthGuy
bset/bclr on SFRs take 2 instruction cycles
goto takes 4 instruction cycles
2020/11/02 03:49:01
microp
Thank you very much for your response.
I don't see that for DSPIC33E , the goto takes 4 cycles.
 
Best regards.
 
Have a good day
2020/11/02 04:00:52
marcov
Note, that for fast togglers it is easier to use an OC peripheral
2020/11/02 08:07:51
1and0
microp
I don't see that for DSPIC33E , the goto takes 4 cycles.

Have you even looked at the "Instruction Set Summary" chapter of YOUR PIC datasheet?!
© 2021 APG vNext Commercial Version 4.5

Use My Existing Forum Account