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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/23/04 02:00
Read: times


 
#81733 - Re: A couple of things - Neil
Responding to: ???'s previous message
Hi Neil, Thank you very much for your reply.

1) doing I/O in a interrupt is always a bad Idea. It means you can not use the I2C bus in most of the rest of the program.


You are right I/O in interrupts is not good. but in my case This interrupt is not always active type It is enabled when RMS Current measurements are to be done and disabled when it is not needed. The portion of the program for which this interrupt is active there is no I2C transactions by main program. Thus possibility of I2C conflict between main program and interrupt can be simply forgotten.

2) Multiplication in a interrupt is a bad Idea. It may cuase a library call, Keil will then push eveything on the stack.


I am doing unsigned char multiplication and getting the result in unsigned char variable. Our 8051 does have 8 bit multiplication instruction thus for unsigned char multiplication there is no need of any library call. and thus shouldn't cause any problem in an interrupt. I have varified this putting SRC directive in top line of my program here is the assembly source generated by keil for that multiplication part.

;   
;   bsqr=bt2*bt2;       //square the sample
			; SOURCE LINE # 2286
	MOV  	A,R5
	MOV  	B,A
	MUL  	AB
	MOV  	R7,A
	MOV  	R6,B
;---- Variable 'bsqr?37231' assigned to Register 'R6/R7' ----


3) keep the using 1 I assume that no other interupt with a higher priority has a using 1, or Keil will push the whole register bank on the stack.


I already tried remove using 1 but problem wasn't sorted out instead three PUSH ARx and three POP ARx got increased in the ISR. Thus I am retaining that using 1.

4) a fix wait is not the correct way to wait for the I2C clock. You are suppose to read it back.


I couldn't get exactly what you mean by reading it back. Please explain a bit more.

have you time the interrupt rate and the interupt time. you could be in the interupt most of the time.


My timer 2 interrupt is occuring every 1333 machine cycles where as time required for ISR execution i only 231 machine cycles. Thus being in interrupt most of the time is very remote possibility.

Thanks Neil for your suggestion.

Regards,
Prahlad Purohit


List of 18 messages in thread
TopicAuthorDate
Timer 2 interrupt with keil.            01/01/70 00:00      
   Additional Information.            01/01/70 00:00      
   what is I2CWAIT;            01/01/70 00:00      
      I2CWAIT is not Function.            01/01/70 00:00      
   Remove            01/01/70 00:00      
      Already tried remove using 1            01/01/70 00:00      
         Timer2 interrupt            01/01/70 00:00      
            Tried making all ISR variables global.            01/01/70 00:00      
               Timer2 Interrupt            01/01/70 00:00      
      Why remove using?            01/01/70 00:00      
      removing using            01/01/70 00:00      
         Re: Remove Using.            01/01/70 00:00      
   int usage            01/01/70 00:00      
      int operations reentrant or not?            01/01/70 00:00      
         varify with asm            01/01/70 00:00      
   A couple of things            01/01/70 00:00      
      Re: A couple of things - Neil            01/01/70 00:00      
         A couple of things            01/01/70 00:00      

Back to Subject List