Operation palReadPad ()

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

Operation palReadPad ()

Postby GianlucaLaManna » Wed Aug 05, 2015 3:48 pm

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: 11148
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 391 times
Been thanked: 321 times
Contact:

Re: Operation palReadPad ()

Postby Giovanni » Wed Aug 05, 2015 3:53 pm

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


Return to “SPC56x Support”

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest