2009-12-11 04:14 PM
About AN2593(STR91x interrupt management)
2011-05-17 01:00 AM
Hello, everyone!
Section 3.4 (page 11/15) wrote: ''Please note that the value 0x18 used in instruction ''ADD r11, r11, #0x18'' is only specific to the example code given here. The offset #0x18 will be dependent on the system's interrupt stacking preamble code size. '' I still don't know how to figure out the ''offset'' in instruction ''ADD r11, r11, offset''. Could you help me? Thank you very much for your help!2011-05-17 01:00 AM
Maybe like this:
void EXTIT1_IRQHandler(void) { DAISY_VIC (); IENABLE; // your code IDISABLE; VIC1->VAR = 0xFF; } DAISY_VIC () is defined somewhere else: #define DAISY_VIC() __asm(''MOV r11, #0xFC000000''); __asm(''ADD r11, r11, #0x30''); \ __asm(''LDR r11, [r11]''); \ __asm(''ADD r11 ,r11 , #0x18''); __asm(''BX r11''); There are five instructions,that's meaning the offset equal 5*4=20 remember that at the very beginning of the function 'EXTIT1_IRQHandler',there is a push instruction(you can find it in asm code),so the offset :6*4=24 0x182011-05-17 01:00 AM
i think its compiler dependent. i also agonized over this offset value since we are using old compiler ADS1.2. what i did was just follow the example file of AN2593 and use the one for CC_ARM. it works fine as it is, although i would not know why. the example source available in stmicro site. if you would understand the meaning of the offset value, i would also be interested how to calculate it.
2011-05-17 01:00 AM
Hi,nle!
I'm not goog at english, but i'll try my best to explain how to calculate it. 'DAISY_VIC()' it self has 5 instructions as follow: #define DAISY_VIC() __asm(''MOV r11, #0xFC000000''); \ __asm(''ADD r11, r11, #0x30''); \ __asm(''LDR r11, [r11]''); \ __asm(''ADD r11 ,r11 , #0x18''); \ __asm(''BX r11''); The interrupt handler function,take ''void EXTIT1_IRQHandler(void)'' as an example,when you translate it to assembly language code,you will find one 'push' instruction at the very begining. So the offset is the size of these six instructions. It is 6*4(one instruction occupy 4 bytes)=24=0x18, that is all! [ This message was edited by: zchongnari on 02-12-2009 11:57 ]2011-05-17 01:00 AM
Well done zchongnari
you get the point! ;)2011-05-17 01:00 AM
i had thought it depends on compiler, because the sample for Tasking and others used 0x18 and the sample code for the RVMDK project uses 0x08 offset. although the code is similar.
from 91x_init.s in RVMDK sample source: DAISY_VIC MOV R11, #0xFC000000 ; VectorAddressDaisy address ADD R11, R11, #0x30 ; VectorAddressDaisy address LDR R11, [R11] ; Update VIC1 hardware priority ADD R11 ,R11 , #0x8 ; Skiping the preambul (+0x08) BX R11 ; Branch to the highest priority ; interrupt from VIC1 So is this a double typing error? (one for the code, another for the comment) [ This message was edited by: nle on 09-12-2009 09:42 ]2011-05-17 01:00 AM
i just rechecked that we are actually using this code in our project as i based it on the RVMDK example (although we are using ADS1.2).
2011-05-17 01:00 AM
There is no rule to find out the skipping preambul.An easy way to calculate it is to put a breakpont when calling DAISY_VIC() function in one of VIC1 interrupt handlers in ''91xit.c'' and look at the dessambly code how much instructions you have from the begining of the interrupt handler until the 1st instruction code starting just after DAISY_VIC().
Normally it should be two 32 bits instructions with the exmaple under RVMDK.2011-05-17 01:00 AM
thanks everyone for very informative information.
incidentally if i dont have debugger (its with the other team, i get by with serial output)is there a way to find out?.. our ADS1.2 dont output assembly lists for C-code (or i dont know how to do it?). updated: ok i asked to check in debugger how it is coded by compiler. in the RVMDK sample it is a branch instruction since it does not use an inline macro like the other examples. so it is correct, 2 instructions translate to 8bytes.[ This message was edited by: nle on 12-12-2009 07:48 ]