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; } }
Sorry to post again, but to make things clear. My situation is that, i want to read the eight bits of data which represented by each ports in port 1 into 1 byte of data.(eg. 0x01,0x34, 0x21). If any of you guys need more information. Please do let me know so that i can help you to help me. Thanks in advance !!
why not ValueX = P1; I am puzzeled Erik
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;