Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/04/00 20:39
Read: times


 
#2073 - RE: 8051 handle short interval interrupts ?
ANSWER: Yes, easily. 50us is a lifetime for even a slow 8051.

Let's put things into perspective. A slow 8051 runs at 12Mhz. Most opcodes run in 12 and 24 ticks and that is 1us and 2us in realtime.

So what must be done in 50us? It depends upon whether you are running fancy multiple tasking or simply running a forground routine to monitor the signal.

You can easily read the signal in either case as long as you don't have a conflicting longer interrupt at a higher level.

I'll make a few example assumptions. Lets assume that you have foreground doing other things and you want the INT0 interrupt to handle this task. The service routine needs to grab a bit and shift it into a reserved byte-building location and probably load those completed bytes into a data buffer. Still easy.

If you haven't consumed all your direct memory, I highly recommend you use your register banks in the low map of memory for various interrupts or better yet for interrupt levels.

; name the four register sets
REG_RUN equ 00000000b ;foreground
REG_NT0 equ 00001000b ;ntr0
REG_NT1 equ 00010000b ;ntr1
REG_NT2 equ 00011000b ;ntr2
org 0003h
v_int0: ;bytes;ticks
ajmp ntr_sig ;2;24
; org elsewhere
ntr_sig:
push psw ;2;24;sav flags
push acc ;2;24;sav acc
mov psw,#reg_nt0 ;3;24
...

that code only took 8us to open a safe environment to run the interrupt - expect about 6us to do the POPs and RETIs. The pop psw will restore the foreground register bank. (24 ticks equals 2us). Stay away from the dptr and b register or else you'll have to push/pop them too.

... ;8us bit to byte routine
mov c,p2.2 ;2;12; get bit
mov a,BUILD ;2;12;
rlc a ;1;12; add bit
mov a,BUILD ;2;12; store
djnz r2,exit ;2;24; done?
mov BYTE,a ;2;12; store byte
mov r2,#8 ;2;12; reload
exit: ;6us exit routine
pop acc ;1;24
pop psw ;1;24
reti ;1;24


Note that a intialize routine would be needed to load the r2 bit counter in the second register bank. The extra time left over could be used to store the bytes or simply set a flag for foreground to remove the completed byte.

-Jay C. Box
sonabouy@yahoo.com


List of 9 messages in thread
TopicAuthorDate
8051 handle short interval interrupts ?            01/01/70 00:00      
RE: 8051 handle short interval interrupts ?            01/01/70 00:00      
RE: 8051 handle short interval interrupts ?            01/01/70 00:00      
RE: 8051 handle short interval interrupts ?            01/01/70 00:00      
RE: 8051 handle short interval interrupts ?            01/01/70 00:00      
RE: 8051 handle short interval interrupts ?            01/01/70 00:00      
RE: 8051 handle short interval interrupts ?            01/01/70 00:00      
RE: 8051 handle short interval interrupts ?            01/01/70 00:00      
RE: 8051 handle short interval interrupts ?            01/01/70 00:00      

Back to Subject List