This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS570LS1224: ultrasonic hc sr-04 with tms570ls1224

Expert 1660 points

Part Number: TMS570LS1224

Hello everyone i want to connect ultrasonic hc sr-04 with tms570ls1224

i connected N2HET1[10]  to the sensor trig

and N2HET1[30] to the sensor echo.

in halcougen i just enabled het1 and  GIO .

i also enabled het1 in PINMUX

and then went to het 1 (pwm 0-7)  in PWM 0 , I changed the period to 10us and selected pin 10 as output pin, and enabled PWM SIGNAL AFTER HETINIT.   in here do i need to change the duty cycle????

then in cap0 i changed the low polarity to high polarity and set pin 30 .

then i went to (pin 8-15) and enabled output direction for bit 10 . In (pin 24-31) i select bit 30 as pullup

i compiled the code but i didn't get any data from the sensor

#include "het.h"
#include "sys_common.h"
#include "gio.h"

hetSIGNAL_t  duration;


float distance;

void main(void)

{

    while(1){
    
    hetInit();
    gioInit(); 

    gioSetDirection(hetPORT1, 0xBFFFFFFF); // 30 Input, 10 Output 
    

   
gioSetBit(hetPORT1, 10, 1); 


    pwmSetDuty(hetRAM1, pwm0, 10U);
    pwmStart(hetRAM1, pwm0);

 capGetSignal(hetRAM1,cap0, &duration);
distance =( duration.period * 0.034) / 2;

}

}