Pages: [1]   Go Down
Author Topic: function "digitalRead(port)" not possible on DUE?  (Read 931 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 3
Posts: 97
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,
i use im my sketch (ported from MEGA) the following function:


digitalWrite(PORT_REL1, PORT_REL_EIN);  //set pin 2 on low or high

and later..

Serial.println(digitalRead(PORT_REL1));     //read pin 2



But the result of the digitalRead() is always 0 in case of some ports (2, 22, 30, 40...) ?
On some other ports (3, 8, 9..) the function works fine.

Is it a bug or a "feature"?

paulinchen
Logged

Offline Offline
Jr. Member
**
Karma: 3
Posts: 97
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,
if i use

Serial.println(PIO_Get(g_APinDescription[PORT_REL1].pPort, PIO_OUTPUT_0, g_APinDescription[PORT_REL1].ulPin));

instead of the buggy digitalRead()-function

it works fine.

paulinchen
Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 64
Posts: 6055
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What is PORT_REL1?
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16525
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

First you should use the proper term

Quote
function "digitalRead(port)"

Port means something else in the AVR/Arduino world, and you are misusing it in this context. You should say:

Quote
function "digitalRead(pin)"

Pin is a single input or output bit
Port is a group of 8 associated I/O bits.

Lefty
Logged

Pages: [1]   Go Up
Jump to: