- Tue Dec 19, 2006 8:05 pm
#23957
Hi,
I've got a shaft encoder interfaced to the msp430, and I'm using interrupts to determine the direction of turning. The shaft encoder has phase A and phase B. The interrupts are set up as following: (Shaft encoder inputs P1.1,P1.2)
Interrupts are normally generated when a transition happens from low to high. However, I've noticed that every now and then, my ISR exectues when one of the phases goes from high to low <- this shouldnt be happening.
(I am using IAR v3.21A) to debug, and monitor the interrupts
Has anyone encountered anything similar? Know a solution? Or could it be that the MSP430 has a problem.
BTW, i am using MSP430F149
Thanks,
Sam
I've got a shaft encoder interfaced to the msp430, and I'm using interrupts to determine the direction of turning. The shaft encoder has phase A and phase B. The interrupts are set up as following: (Shaft encoder inputs P1.1,P1.2)
Code: Select all
The interrupt routine://Port1:
// Port External Functions:
P1SEL=0x00;
// Port Setup outputs:
P1DIR=BIT3+BIT5;
// Port Interrupts:
P1IE=BIT1+BIT2;
P1IES=0x00; // select triggering from low to high
P1IFG=0x00; // clear all interrupts
Code: Select all
Now, the problem is: if(P1IFG&BIT1){
if(SHAFT_A) shaft_direction=1; // if phase A is high, we are going CW
P1IFG&=~BIT1; // clear interrupt
}
if(P1IFG&BIT2){
if(SHAFT_B) shaft_direction=2; // if phase B is high, we are going CCW
P1IFG&=~BIT2; // clear interrupt
}
Interrupts are normally generated when a transition happens from low to high. However, I've noticed that every now and then, my ISR exectues when one of the phases goes from high to low <- this shouldnt be happening.
(I am using IAR v3.21A) to debug, and monitor the interrupts
Has anyone encountered anything similar? Know a solution? Or could it be that the MSP430 has a problem.
BTW, i am using MSP430F149
Thanks,
Sam