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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/26/00 08:07
Read: times


 
#3984 - Rotary knob and INT in C
I use an 89C52 (XTAL 4MHz) )with a rotaty knob (with 30 click for one turn ; BUT at each click the level is both 1 or 0). This knob is connected at INT0 (PIN 12) and at PIN 14.

What I want :
If I turn the knob slowly, the increment (or decrement) is 1.
If the speed is higher, the increment (or decr.) is multiply by 4.
I use INT because I want to put the 89C52 in Idle mode.

The problem is :
The 89C52 can’t interrupt when the level go from loe to high.
If I go UP slowly the increment is sometime by 2 ?
If I do DOWN sometimes the increment is by 1 !

If anybody can help me….

Thank in advance.
Sylvain


#pragma CODE
#include <reg51.h>
#include <display.h>

sbit POT_A =P3^4;
sbit POT_B =P3^2;

unsigned int Number;
signed char Sens;
bit Old_POT_A;

void main(void)
{
initdisp();
printf("HELLO");
IT0=1; /* d‚clenchement sur les flancs */
EA=1; /* enable all int */
EX0=1; /* enable int0 */
Number=0;
while(1)
{
gotoxy(1,2);
printf("%05u",Number);
EX0=1; /* enable int0 */

}
}
void digital_pot(void) interrupt 0
{
EX0=0; /* disable int0 */
Old_POT_A= POT_A;
while (POT_A!=POT_B)
{
}
if(POT_A==Old_POT_A) Number=Number+1;
else
Number=Number-1;
}





List of 13 messages in thread
TopicAuthorDate
Rotary knob and INT in C            01/01/70 00:00      
RE: Rotary knob and INT in C            01/01/70 00:00      
RE: Rotary knob and INT in C            01/01/70 00:00      
RE: Rotary knob and INT in C            01/01/70 00:00      
RE: Rotary knob and INT in C            01/01/70 00:00      
RE: Rotary knob and INT in C            01/01/70 00:00      
RE: Rotary knob and INT in C            01/01/70 00:00      
RE: Rotary knob and INT in C            01/01/70 00:00      
RE: Rotary knob and INT in C            01/01/70 00:00      
RE: Rotary knob and INT in C            01/01/70 00:00      
RE: Rotary knob and INT in C            01/01/70 00:00      
RE: Rotary knob and INT in C            01/01/70 00:00      
RE: Rotary knob and INT in C            01/01/70 00:00      

Back to Subject List