i wan't to get Inputs to my Atmega16L from a Button. Ideally i can use the internal Pull-up's, so i don't have to attach them externally.
I've boiled down the code to the minimum:
void main(void) {
// SFIOR &= ~(1<<PUD); // Turn off Pull-up disable
DDRD = 0xFF; // Output PORT D
DDRA = 0x00; // Input PORT A
PORTA = 0xFF; // Pull-up on PORT A
_delay_ms(100);
while (1)
{
if (PINA & (1<<PA1)) // Check if PA0 is High
PORTD |= (1<<PD5); // Set PD5 to High
else
PORTD &= ~(1<<PD5); // Set PD5 to Low
}
return;}
I would expect, the Pin PD5 should be high, because the PA1 is pulled up by the internal pull-up, set on line 6. But no, when i run the code, the Pin PD5 is low, and i have to connect the Pin PA1 to 5V, in order to get a High Signal on PD5.
Short things Short, it looks like the pull-up isn't active...
If tried working with the SFIOR, but the PUD is disabled by default, as far as i know.
kind regards, Felix
EDIT: the requested Images: