Connect with us

AVR AT90S2313 basic question

Discussion in '8bit Microcontrollers' started by Jean Tabel, Nov 6, 2004.

Scroll to continue with content
  1. Jean Tabel

    Jean Tabel Guest


    I am experimenting for the fist time with PB0 connected to a LED
    and PB1 configured (?) as an input.

    PB1 is directly connected to the GND, and I was assuming the LED
    would stay on until I would connect it directly to VCC.

    But I am executing outp (0x00, PORTB).
    When this line is commented out, the LED stays on.

    void main (void)
    outp (0x01, DDRB); // PB0 output, PB1 input
    outp (0x01, PORTB); // LED on PB0 set to on

    for (;;) {
    if (inp(PINB) & 0x02 != 0) {
    // logical 1 in PB1 - setting LED on PB0 to off
    outp (0x00, PORTB);

    I tried to activate the pull-up internal resistor for PB1 by writing
    0x03 into PORTB instread of 0x01, but this dis not change

    Since I am basically a software guy, I must probably be missing
    something very, very trivial.

    Any clue anybody ?

    Thanks in advance,

    Jean Tabel
  2. Ken Scharf

    Ken Scharf Guest

    Try it this way:
    if (inp(PINB) & 0x02) { //if pinb1 input high next statement executed
    // logical 1 in PB1 - setting LED on PB0 to off
    outp (0x00, PORTB);
    Also you might add an external pull up resistor, put your
    input switch from pb1 to ground.
  3. Jean Tabel

    Jean Tabel Guest

    The external pull-up resistor did the job, thank you very much.
    Jean Tabel
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day