2008-11-11 11:54:37 NMI TROUBLE
Aldric Molina (SWITZERLAND)
Message: 65036
Hello everybody,
For my industrial project, I use a NMI to make a pulse in a gpio pin.
When the NMI signal is up, I enter in the NMI and do :
___________________________________________________________________________
P0.h = FIO_FLAG_S_HIGH;
P0.l = FIO_FLAG_S_LOW;
R1 = 0x0100; /*Change l'etat de PF8*/
W[P0] = R1;
___________________________________________________________________________
At the end of the NMI I do (I have no other instruction between the two block of code) :
___________________________________________________________________________
P0.h = FIO_FLAG_C_HIGH;
P0.l = FIO_FLAG_C_LOW;
R1 = 0x0100; /*Change l'etat de PF8*/
W[P0] = R1;
___________________________________________________________________________
When I try this code,
I have the rising edge of the signal in the gpio OK.
The falling edge must be about 20ns after the rising edge but in my case it is about 200ns!
In addition, when I have interrupt (like the keyboard) the time between the rising edge and the falling edge is bigger.
I know that is a special case but thanks for reply.
Best regards
Aldric MOlina
TranslateQuoteReplyEditDelete
2008-11-11 12:06:38 Re: NMI TROUBLE
Mike Frysinger (UNITED STATES)
Message: 65037
you should use SSYNC to make sure changes are committed, and you can do that in a lot less statements:
P0.h = HI(FIO_FLAG_S);
P0.l = LO(FIO_FLAG_S);
R1 = 0x100;
w[P0] = R1;
w[P0 + FIO_FLAG_S - FIO_FLAG_C] = R1;
QuoteReplyEditDelete
2008-11-11 12:22:43 Re: NMI TROUBLE
Aldric Molina (SWITZERLAND)
Message: 65038
Ok, thank's for the fast reply. I try that now.
TranslateQuoteReplyEditDelete
2008-11-11 12:37:21 Re: NMI TROUBLE
Aldric Molina (SWITZERLAND)
Message: 65039
It's very strange. I have the same problem with the ssync!
The code is:
__________________________________________________________________________________
P0.h = HI(FIO_FLAG_S);
P0.l = LO(FIO_FLAG_S);
R1 = 0x100;
w[P0] = R1;
ssync;
w[P0 + FIO_FLAG_S - FIO_FLAG_C] = R1;
ssync;
__________________________________________________________________________________
It s smaller and more funny code (thank's Mike) but the falling edge of the signal is after 200ns! And when I hold <enter> I have more than 600ns!
Do you have an idea of the problem?
TranslateQuoteReplyEditDelete
2008-11-11 12:44:20 Re: NMI TROUBLE
Mike Frysinger (UNITED STATES)
Message: 65041
if you want to guarantee things, you should make sure the code is placed in L1 ... otherwise, dma traffic will be contending for external memory access
QuoteReplyEditDelete
2008-11-11 12:51:42 Re: NMI TROUBLE
Aldric Molina (SWITZERLAND)
Message: 65042
I think it's ok, all the code must be in the L1.
If you want to verify, my code si down.
Thank's
Aldric
The NMI code:
_______________________________________________________________________________________________________________
#include <asm/blackfin.h>
#include <asm/mach/irq.h>
#include <linux/linkage.h>
#include <asm/entry.h>
#include <asm/asm-offsets.h>
#include <asm/trace.h>
#include <asm/traps.h>
#include <asm/thread_info.h>
#include <asm/mach-common/context.S>
#ifndef CONFIG_BFIN_SCRATCH_REG_CYCLES
# error "A safe NMI handler (that uses stack) only works with the CONFIG_BFIN_SCRATCH_REG_CYCLES option"
#endif
.section .l1.data
_nmi_stack:
.rept 512;
.long 0;
.endr
_nmi_stack_top:
.previous
ENTRY(_evt_nmi)
/* safe the old stack pointer */
RETE = SP;
/* load up our NMI stack which is in L1 */
SP.l = _nmi_stack_top;
SP.h = _nmi_stack_top;
/* save all core registers */
[--sp] = SYSCFG;
[--sp] = P0; /* orig_p0 */
[--sp] = R0; /* orig_r0 */
[--sp] = ( R7:0, P5:0 );
[--sp] = fp;
[--sp] = usp;
[--sp] = LC0;
[--sp] = LC1;
[--sp] = LT0;
[--sp] = LT1;
[--sp] = LB0;
[--sp]= LB1;
[--sp] = ASTAT;
[--sp] = r0;
[--sp] = RETS;
r0 = RETI;
[--sp] = r0;
[--sp] = RETX;
[--sp] = SEQSTAT;
[--sp] = r0;
/* Traitment de la nmi*/
P0.h = HI(FIO_FLAG_S);
P0.l = LO(FIO_FLAG_S);
R1 = 0x100;
w[P0] = R1;
ssync;
w[P0 + FIO_FLAG_S - FIO_FLAG_C] = R1;
ssync;
/* restore all core registers */
sp += 4; /* Skip IPEND */
SEQSTAT = [sp++];
RETX = [sp++];
r0 = [sp++];
RETI =r0; /* Restore RETI indirectly when in exception */
RETS = [sp++];
sp += 4; /* Skip Reserved */
ASTAT = [sp++];
LB1 = [sp++];
LB0 = [sp++];
LT1 = [sp++];
LT0 = [sp++];
LC1 = [sp++];
LC0 = [sp++];
sp += 4;
fp = [sp++];
( R7 : 0, P5 : 0) = [ SP ++ ];
R0 = [sp++]; /* orig_p0 */
P0 = [sp++]; /* orig_r0 */
SYSCFG = [sp++];
/* restore the old stack pointer*/
SP = RETE;
/* exit nmi handler*/
RTN;
ENDPROC(_evt_nmi)
TranslateQuoteReplyEditDelete
2008-11-11 12:55:16 Re: NMI TROUBLE
Mike Frysinger (UNITED STATES)
Message: 65043
were you asking a question ? because that code is not in L1.
QuoteReplyEditDelete
2008-11-11 13:00:37 Re: NMI TROUBLE
Aldric Molina (SWITZERLAND)
Message: 65044
Yes, excuse me. It was a question.
What should I modify to put this code in L1?
TranslateQuoteReplyEditDelete
2008-11-11 13:06:16 Re: NMI TROUBLE
Mike Frysinger (UNITED STATES)
Message: 65045
please review the documentation:
http://docs.blackfin.uclinux.org/doku.php?id=using_l1_memory
http://docs.blackfin.uclinux.org/doku.php?id=load_driver_module_into_l1_memory
QuoteReplyEditDelete
2008-11-11 13:22:34 Re: NMI TROUBLE
Aldric Molina (SWITZERLAND)
Message: 65046
It's right if I put the ".section .l1.text" after the "ENTRY(_evt_nmi)" to have all my code in L1 memory?
TranslateQuoteReplyEditDelete
2008-11-11 13:23:41 Re: NMI TROUBLE
Aldric Molina (SWITZERLAND)
Message: 65047
Why I try my code and I have the same problem!
TranslateQuoteReplyEditDelete
2008-11-11 13:37:49 Re: NMI TROUBLE
Aldric Molina (SWITZERLAND)
Message: 65048
To anderstand my problem, I attach a print screen of my oscilloscope.
The yellow trace is the signal NMI and the grenn one is the gpio pin.
We can see that I have a delai about 100ns beteween wake up of the NMI and the rising edge of the gpio. It not a problem why it's constant. (In greay we can see the persistant mode)
The problem is the no constant time between the rising edge and falling edge of the signal gpio.
Can you tell me why I have this probleme?
When I push <enter> that made big time!!
scope_1.png
TranslateQuoteReplyEditDelete
2008-11-11 13:49:14 Re: NMI TROUBLE
Mike Frysinger (UNITED STATES)
Message: 65049
the assembler processes things in order. symbols belong to whatever the current section is when the symbol is defined.
why are you pushing so much stuff onto the stack ? you should only push what you actually use.
QuoteReplyEditDelete
2008-11-11 13:55:31 Re: NMI TROUBLE
Aldric Molina (SWITZERLAND)
Message: 65050
If I have right, I must push only the R1 and P0 ont the stack? I need to push more thing?
TranslateQuoteReplyEditDelete
2008-11-11 15:07:35 Re: NMI TROUBLE
Aldric Molina (SWITZERLAND)
Message: 65054
When I push only the P0 and R1 register, the problem is the same. I have a no constant delai!
Thank's for the time passed to my problem.
Aldric Molina
TranslateQuoteReplyEditDelete
2008-11-11 15:49:32 Re: NMI TROUBLE
Jean-Christian de Rivaz (SWITZERLAND)
Message: 65058
Did the delay between the NMI signal and the GPIO change when saving only P0 and R1 compared to your previouse version that save more registers ? The NMI signal is active high but the yello signal on your graph seem to be active low, strange.
Maybe can you print the NMI handler addess to be certain it is in L1.
Regards,
Jean-Christian
QuoteReplyEditDelete
2008-11-11 17:33:11 Re: NMI TROUBLE
Aldric Molina (SWITZERLAND)
Message: 65062
Dear Jean-Christian,
You are right for our second purpose. The signal in the graph is the /NMI (excuse me for the error).
When I push only the two register, the time between the nmi and the gpio don't change but the time between the rising edge and falling edge of the gpio is smaller! That's very strange.
For your last purpose, it's a good Idea. I'll try it tomorow.
Thanks for the answer.
Best regards.
Aldric Molina
TranslateQuoteReplyEditDelete