Altera_Forum
Honored Contributor
21 years agoDSR not called
Dear Forum readers
I've been scrathing my head for some time over this. I have a custom board that gives me a periodic interrupt. I've written a ISR- DSR handler pair and they work - sometimes. I've stripped the code down and the two examples is the essence of my problem. The first one works as expected - in the second the DSR is never called, but apart from that the rest of the system performs as it should. As seen the ONLY change is that abe++ has been replaced with 3 nops - just to make it easier to compare objdumps. The objdumps of the complete program are identical apart from the sections shown, so the all variables, functions etc reside in identical places. The compiler has chosen different registers in the two examples, but I really cannot see anything illigal in this assembler code. Please have a look - this is beyond me http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/ohmy.gif -- working --cyg_uint32 avr_isr_function(cyg_vector_t vector, cyg_addrword_t data)
{
cyg_interrupt_mask( vector );
cyg_interrupt_acknowledge( vector );
// Acknowlege
Data = IORD_32DIRECT(AVRIF_BASE,0);
for (i=0;i<8;i++) {
Data = IORD_32DIRECT(AVRIF_BASE,i*4+4);
IOWR_32DIRECT(AVRIF_BASE,i*4+4,buf1);
asm("nop;nop;nop");
} // endfor
abe += 8;
return CYG_ISR_CALL_DSR;
}
void avr_dsr_function(cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t data)
{
// Unmask it
abe++;
cyg_interrupt_unmask( vector );
}
objdump
Data = IORD_32DIRECT(AVRIF_BASE,i*4+4);
8004b0: d3601917 ldw r13,-32668(gp)
8004b4: 681890ba slli r12,r13,2
8004b8: 62066104 addi r8,r12,6532
8004bc: 42800037 ldwio r10,0(r8)
IOWR_32DIRECT(AVRIF_BASE,i*4+4,buf1);
8004c0: 6197883a add r11,r12,r6
8004c4: 5a400017 ldw r9,0(r11)
8004c8: d2a01a15 stw r10,-32664(gp)
8004cc: 42400035 stwio r9,0(r8)
asm("nop;nop;nop");
8004d0: 0001883a nop
8004d4: 0001883a nop
8004d8: 0001883a nop
8004dc: d1601917 ldw r5,-32668(gp)
8004e0: 29000044 addi r4,r5,1
8004e4: d1201915 stw r4,-32668(gp)
8004e8: 393ff10e bge r7,r4,8004b0 <_Z16avr_isr_functionjj+0x38> -- disfunctional-- cyg_uint32 avr_isr_function(cyg_vector_t vector, cyg_addrword_t data)
{
cyg_interrupt_mask( vector );
cyg_interrupt_acknowledge( vector );
// Acknowlege
Data = IORD_32DIRECT(AVRIF_BASE,0);
for (i=0;i<8;i++) {
Data = IORD_32DIRECT(AVRIF_BASE,i*4+4);
IOWR_32DIRECT(AVRIF_BASE,i*4+4,buf1);
abe++;
} // endfor
abe += 8;
return CYG_ISR_CALL_DSR;
}
void avr_dsr_function(cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t data)
{
// Unmask it
abe++;
cyg_interrupt_unmask( vector );
}
objdump:
Data = IORD_32DIRECT(AVRIF_BASE,i*4+4);
8004b0: d3e01917 ldw r15,-32668(gp)
8004b4: 781c90ba slli r14,r15,2
8004b8: 72866104 addi r10,r14,6532
8004bc: 53000037 ldwio r12,0(r10)
IOWR_32DIRECT(AVRIF_BASE,i*4+4,buf1);
8004c0: 719b883a add r13,r14,r6
8004c4: 6ac00017 ldw r11,0(r13)
8004c8: d3201a15 stw r12,-32664(gp)
8004cc: 52c00035 stwio r11,0(r10)
abe++;
8004d0: d2600417 ldw r9,-32752(gp)
8004d4: d2201917 ldw r8,-32668(gp)
8004d8: 49400044 addi r5,r9,1
8004dc: 41000044 addi r4,r8,1
8004e0: d1600415 stw r5,-32752(gp)
8004e4: d1201915 stw r4,-32668(gp)
8004e8: 393ff10e bge r7,r4,8004b0 <_Z16avr_isr_functionjj+0x38>