bugSearduino - Bugs: bug #36220, Read status of output pin

 
 

bug #36220: Read status of output pin

Submitted by:  None
Submitted on:  Tue 17 Apr 2012 07:02:17 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: Henrik Sandklef <hesa>
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 17 Apr 2012 07:48:06 AM UTC, comment #1:

This seems to have been solved with the latest release, but there is still code in the wiring_digital that states

if ( get_digital_pin_mode(pin) != INPUT )
{
fprintf(stderr,
"Can't read from a pin (%d) with mode (%d) NOT set INPUT\n",
pin, get_digital_pin_mode(pin));
log_error("Can't read from an OUTPUT pin");
SEARD_ERROR(SEARD_ARDUINO_WRONG_PIN_MODE);
return 0;
}

Peter Myllykoski <whitedice>
Project Administrator
Tue 17 Apr 2012 07:02:17 AM UTC, original submission:

Reading the status of a output pin is not possible. According to the manual of AVR and the observed behaviour of arduino this should be possible.

In AVR you can write a short blink program in the following way:

#include <avr/io.h>
#include <util/delay.h>

void setup_led(void) {
DDRB |= (1<<PB7);
PORTB = 0x00;
}

void main_loop(void) {
for(;;) {
(PINB & (1<<PB7)) ? (PORTB &= ~(1<<PB7)) : (PORTB |= (1<<PB7));
_delay_ms(300);
}
}

int main(void) {
setup_led();
main_loop();
}

In the Arduino IDE the following is a short version of blink

void setup() {
pinMode(13,OUTPUT);
}

void loop() {
digitalRead(13) ? digitalWrite(13,LOW) : digitalWrite(13,HIGH);
delay(300);
}

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by hesa (Updated the item)
  • -unavailable- added by whitedice (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 17 Apr 2012 12:10:24 PM UTChesaStatusNone=>Fixed
      Assigned toNone=>hesa
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1