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.

Implementation of ultrasonic sensor on Hercules TMS570LC4357

Other Parts Discussed in Thread: TMS570LC4357, HALCOGEN

Hi guys,

i am trying to read the values of a ultrasonic sensor using tms570lc4357 .It is a 3 pin ultrasonic sensor .

This is my code 

int main(void)
{
/* USER CODE BEGIN (3) */
int q,n;
sciInit();
adcInit();
adcData_t p;

while(1)
{
adcStartConversion(adcREG1,adcGROUP1);
adcGetData(adcREG1,1U,&p);
q=(unsigned int)p.value;

n=ltoa(q, (unsigned char*)command);
sciSend(sciREG1, 8, (unsigned char *)"VALUE = ");
sciSend(sciREG1, n, command);
sciSend(sciREG1, 2, (unsigned char *)"\r\n");
}

The ultrasonic is connected to adin_26 pin on the board and i have enables adc and sci in halcogen. I have assigned a FIFO size of  1 bit and data resolution of 8 bits. Adc trigger event is set at rising edge and the trigger mode is hardware mode and the HW trigger source  is event.

I am not able to find out the mistakes.

  • Hello Mukesh,

    This sounds very complicated for a first pass implementation. I would simplify to get the ADC readings working first. i.e., remove the triggers unless they are absolutely necessary to synchronize with the sensor and remove the SCI transmit unless this the only way you have to debug. Also, why are you using such low resolution on the ADC. Why not use the default 12-bit? Also, which board are you using? Can you also explain again what FIFO size you are using? 1 bit is not an option. If you have only one conversion happening, there really is no need to use anything other than the default FIFO size.

    Note that there are examples available in Halcogen for setting up and using the ADC. I would strongly encourage you to have a look at them and use the demo to configure your ADC. In fact, the example example_adcDisplay.c sounds like it aligns perfectly with what you are trying to do short of hooking up the sensor.