I'm having a problem with collecting data from Port1. the variable ValueX has a value of FF, regardless of my input through the IO pins.With here i enclose partial of my code, any help or advice is highly appreciated, thank you!
sbit P1^0 BIT0; //these 8 ports will be input . . . . sbit P1^7 BIT7; signed char ValueX = 0x00; . . void ReadValue(void); void main() { P1 = 0xFF; //port set high to activate as input . . } void ReadValue(void) interrupt 0 using 0 { . . . ValueX = ValueX | BIT0; ValueX = (ValueX <<1) | BIT1; ValueX = (ValueX <<1) | BIT2; ValueX = (ValueX <<1) | BIT3; ValueX = (ValueX <<1) | BIT4; ValueX = (ValueX <<1) | BIT5; ValueX = (ValueX <<1) | BIT6; ValueX = (ValueX <<1) | BIT7; } }
Unless you're just not showing this in your code snippet, you don't seem to be resetting ValueX inside the ISR and you're only performing OR (|) operations on the data. So once you read 0xFF one time, it's never going to change. Perhaps just throwing
ValueX = 0x00;