Hello,
I've connected 4 buttons to my avr mega 16 and they should be active low.
The code I use is:
for(;;) // Infinite loop { AvrXDelay(&MyTimer3, 5); if( bit_is_clear( PORTC , PINC0 ) == 1 ) // check if low { AvrXDelay(&MyTimer3, 100); // Dake care of disco stuff while( bit_is_clear( PORTC , PINC0 ) == 1 ) // Wait until released { AvrXDelay(&MyTimer3, 1); } AvrXSendMessage(&button,&right); AvrXWaitMessageAck(&right); } if( bit_is_clear( PORTC , PINC1 ) == 1 ) // check if low { AvrXDelay(&MyTimer3, 100); // Dake care of disco stuff while( bit_is_clear( PORTC , PINC1 ) == 1 ) // Wait until released { AvrXDelay(&MyTimer3, 1); } AvrXSendMessage(&button,&right); AvrXWaitMessageAck(&right); } if( bit_is_clear( PORTC , PINC2 ) == 1 ) // check if low { AvrXDelay(&MyTimer3, 100); // Dake care of disco stuff while( bit_is_clear( PORTC , PINC2 ) == 1 ) // Wait until released { AvrXDelay(&MyTimer3, 1); } AvrXSendMessage(&button,&right); AvrXWaitMessageAck(&right); } if( bit_is_clear( PORTC , PINC3 ) == 1 ) // check if low { AvrXDelay(&MyTimer3, 100); // Dake care of disco stuff while( bit_is_clear( PORTC , PINC3 ) == 1 ) // Wait until released { AvrXDelay(&MyTimer3, 1); } AvrXSendMessage(&button,&right); AvrXWaitMessageAck(&right); } }
Now I've defined portc all inputs. And I've tested all buttons so that they work as they should but... How come only pinc0 works and no other pins? I've even tried this on porta and portd and it makes no difference.
Thank you very much.
/Gert