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.