Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Delay Overlap Issue

Status
Not open for further replies.

Suraj143

Active Member
In my LED moving sign I have 8 rows & 40 Columns.
At each interrupt I update 1 row at a time.The animation patterns are in the main loop. The code works.

The only doubt is my subroutine processing times are larger than the interrupt rate (1mS) so it may generate interrupt while I'm processing my subroutine process.

How to overcome this?

Thanks


Code:
Isr_Rate = 1mS

Do_Mux            ---

Do_Row_1        ---
                goto    Mux_Exit
Do_Row_2        ---   
Do_Row_3        ---       
Do_Row_4        ---       
Do_Row_5        ---       
Do_Row_6        ---       
Do_Row_7        ---           
Do_Row_8        ---   
                bsf,Flag_Register,End_Frame        ;8mS Time   
Load_Disp_Buffer   
                copy working regs to display registers           

Mux_Exit        


;===========================================================
Main_Routine
           
Do_Pat_1        call    Subroutine_1            ;250uS time   
                call    Subroutine_2            ;100uS Time
                call    Subroutine_3            ;560uS Time
                call    Subroutine_4            ;380uS Time
                call    Delay_40mS
               
               
               
;=======================================================               
Delay_40mS        movlw    .5
                movwf    Count        ;8mS X 5 = 40mS
Delay_Loop        bcf        Flag_Register,End_Frame
                btfss    Flag_Register,End_Frame
                goto    $-1
                bcf        Flag_Register,End_Frame
                decfsz    Count,F
                goto    Delay_Loop
                return

;========================================================               
Subroutine_1    --
                Return

Subroutine_2    --
                Return

Subroutine_3    --
                Return

Subroutine_4    --
                Return
 
Last edited:
Speed up your subroutines or slow down the interrupt - try 2mS. This will still give a refresh rate of ~60 fps.

Mike.
 
Hi thanks.

I have a small doubt.Even though interrupt happens while in the middle of pattern update routines it wont show on display, because the display registers will update after each frame that is 8mS time...!!!
 
I assumed the interrupt displayed 1 pattern and returned and hence it would update every 2mS to give a refresh rate of ~60Hz. Note, if your timer interrupt happens before the ISR has finished then your main program will never run.

Mike.
 
ISR routine is only for multiplexing part (Just Row update).Patterns are loading in the main routine.There are two register sets.One set is working registers (Pattern loading registers) & the other set is Display registers (used only in ISR routine) now you got it..!!!
 
So your ISR is just writing 40 columns and then turning on the appropriate row. So, why can't you make your ISR only fire every 2mS to give yourself more time? How are you generating the interrupt?

Mike.
 
So your ISR is just writing 40 columns and then turning on the appropriate row. So, why can't you make your ISR only fire every 2mS to give yourself more time? How are you generating the interrupt?

Mike.
Exactly now you got it.I need over 100Hz refresh rate.

Like I said earlier I think the Timer overflow interrupt never get crashed.Because in the ISR its is only dealing with display registers.The pattern working registers only will update end of frame that is 8mS time.So I have 8mS time to do my pattern stuff & it will never get crashed.....
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top