This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Interrup Register Bank

Dear All,

I'm using this interrupt on my program

void timer1_ISR (void) interrupt 3 //timer1 interrupt services routine
{
..
}

void it_ext1(void) interrupt 2	// external interrupt INT1
{
..
}

void timerisr(void) interrupt 1   //timer0 interrupt services routine
{
..
}

static void com_isr (void) interrupt 4  //SERIAL COMMUNICATION INTERRUPT SERVICES ROUTINE
{
..
}


void i2c(void) interrupt 5    //i2c interrupt services routines
{
..
}




and I didn't specified which register bank to use on every interrupt routines.

does it can crash my program?

I've seen few example which specified the register bank.

Can anyone explain more on the uses of register bank during interrupt service routine


Thanks
Juru Dala

PS: I'm using 668 chip

Parents
  • hi,
    You can use the same register bank for each ISR that is at the same interrupt level.

    ...as long as you do not use these registers as variables. There are tasks for which the speed is most important. In such case, usage of the registers to keep ISR's data is rather than memory locations.
    For example, one of my projects uses timer 2 for control PWM of PCA which plays sound. As digital stream frequence is about 22kHz and so ISR of timer 2 executes each ~45us. This ISR updates PWM with previously prepared value, checks is sound playback done, if not then reads next byte from external flash memory. Due lack of execution time I decided to keep flash memory address (3 bytes) and playback length (3 bytes) into R1...R6 of register bank I set for the ISR. You know, it increases the speed very well.

    Regards,
    Oleg

Reply
  • hi,
    You can use the same register bank for each ISR that is at the same interrupt level.

    ...as long as you do not use these registers as variables. There are tasks for which the speed is most important. In such case, usage of the registers to keep ISR's data is rather than memory locations.
    For example, one of my projects uses timer 2 for control PWM of PCA which plays sound. As digital stream frequence is about 22kHz and so ISR of timer 2 executes each ~45us. This ISR updates PWM with previously prepared value, checks is sound playback done, if not then reads next byte from external flash memory. Due lack of execution time I decided to keep flash memory address (3 bytes) and playback length (3 bytes) into R1...R6 of register bank I set for the ISR. You know, it increases the speed very well.

    Regards,
    Oleg

Children
  • Graham Cole said:
    "You can use the same register bank for each ISR that is at the same interrupt level."

    Oleg Sergeev replied:
    "...as long as you do not use these registers as variables."

    Oleg: Presumably you are doing this in Assembler, not 'C'?

    I did wonder about the kind of thing you're suggesting, but I couldn't immediately see how you'd do it in C51.

  • hi,

    yes, Andy, ISR was wrote with ASM (actually it must be wrote such way as it requires high-speed optimization I done with hands). Then it was placed in separate .A51 file together with other ASM routines.
    Inside ASM I used bank switching, like:

    	CSEG	AT  0x002B  ; TF2
    	LJMP	INT2_ISR
    ; ...
    
    INT2_ISR_SEG SEGMENT CODE
    	RSEG INT2_ISR_SEG
    	USING 1	; register bank 1
    INT2_ISR:
    	PUSH	PSW
    	MOV	PSW,#REGBANK_1
    ; ....
    	POP	PSW
    	RETI
    
    Main program is done with C. No problems to declare absolute variable locations, something like:
    data struct
    {
    	unsigned char fa_lb;
    	unsigned char fa_mb;
    	unsigned char fa_hb;
    } flash_addr  _at_ 0x09;
    data struct
    {
    	unsigned char pbl_lb;
    	unsigned char pbl_mb;
    	unsigned char pbl_hb;
    } playback_length  _at_ 0x12;
    
    

    Indeed I was noticed about data memory overlap but it is just a warning (=

    Regards,
    Oleg

  • oops,
    I did a typpo. second structure is defined from 0x0C.

    Sorry,
    Oleg