Operation palReadPad ()

ChibiOS public support forum for topics related to the STMicroelectronics SPC56x family of automotive micro-controllers.
Post Reply
GianlucaLaManna
Posts: 25
Joined: Fri Mar 13, 2015 12:12 pm

Operation palReadPad ()

Post 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.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Operation palReadPad ()

Post 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
Post Reply