Page 1 of 1

Operation palReadPad ()

Posted: Wed Aug 05, 2015 3:48 pm
by GianlucaLaManna
Hello.

This is my code:

Code: Select all

static WORKING_AREA(waThread1, 128);
static msg_t Thread1(void *arg) {

  (void)arg;
  chRegSetThreadName("detection");

  int count=0;
  while (TRUE) {
   //  uint32_t duration, distanceCm;
          palClearPad(PORT_A, TRIG_PIN); // low
          osalThreadSleepMicroseconds(2);
          palSetPad(PORT_A, TRIG_PIN); //high
          osalThreadSleepMicroseconds(10);
          palClearPad(PORT_A, TRIG_PIN); // low
          osalThreadSleepMilliseconds(2000);
          palSetPad(PORT_A, ECHO_PIN);
         // count++;
        chprintf((BaseSequentialStream *)&SD1,"Firts Count: %u\r\n", palReadPad(PORT_A,ECHO_PIN));

Why the function palReadPad return always 0?

I use an ultrasonic sensor HY-SRF05 and my echo pin is mapped with pinmap wizard on pin 84 (A2).
Thanks.

Gianluca.

Re: Operation palReadPad ()

Posted: Wed Aug 05, 2015 3:53 pm
by Giovanni
Hi,

It depends on the pin configuration, if the pin is not programmed as output, push-pull WITH read-back then it cannot be read. See the SIUL chapter in the reference manual.

Giovanni