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.

TMS570LS0432 ADC

Hi,

   I have four channels analog valtage to collect:0.64V,0.53V,1.89V,2.78V. The reference voltage is 3.3V and GND. I use 12bits resolution,so the digital convertion results are as follows:800,664,2346,3456. Then I use ADC1 Group1 channel0,1,2,4. when I use CAN send the digital result,the channel0,1,4 are all right,only the channel2 digital result is wrong. The value is 864.The id is right. what's wrong ?

The part  code as following:

void main(void)
{
/* USER CODE BEGIN (3) */
uint32 ch_count ;
uint32 id =0;
uint32 value =0;
adcInit();
canInit();
while(1)
{
adcStartConversion(adcREG1,adcGROUP1);

while((adcIsConversionComplete(adcREG1,adcGROUP1))==0);
ch_count = adcGetData(adcREG1, adcGROUP1,&adc_data[0]);
ch_count = ch_count;

id = adc_data[0].id;
value = adc_data[0].value;
tx_data[0]= value&0xff;
tx_data[1]= value>>8;
tx_data[2]= id;
tx_data[3]=ch_count;
canTransmit(canREG1, canMESSAGE_BOX1, tx_data);

}

 

  

  • sorry,repeated problem due to bad network
  • The digital result is right when the channel 2 is selected only.once other channels is selected,the channel2's result is wrong.Later,I change other controller to test,all the results are right. It is a strange thing...
  • I would suggest to check if the error is repeatable when you see it next time. You also need to check the level of analog inputs. To make the debug easier, save the data from A/D to a global data array so that you can see if it is really an A/D issue or something else.

    Thanks and regards,

    Zhaohong
  • Hi,Zhaohong,
    Thank you for your help.There is repeatable error in a controller .The problem confused me two days,so I change other controllers to test.Unbelievable,that's true.About your suggestion:
    1) Actually,I collect voltage on resistance.In this forum,I give the voltage values on resistance and corresponding digital values above.
    2)when MCU was working, I have measured the voltage which was direct connected to ADIN02.The voltage value is right,but the digtal result is wrong.
    3)The tx_data array is defined and initialized before main function.It is a global array.
    In fact, I have a little confused :
    1.when my resistance load are not connect,the voltage is 5V in direct conncet to ADIN channel.Is it affect ADIN channel?what will happen(all my MCU reference voltage is 3.3V)
    2.The group1 have 8 buffers.In the code,we always read the buffer0.My understanding as follows:when we read out the first result in buffer0,then the second channel result put into the buffer0,then we read the second result,and so on?buffer1-buffer7 are not used?
    3.If I used continuous conversion,which the register can judge the conversion completed?GxINTFLG or status register?They all have GX_END.

    Jackee Wu
    Best regards
  • I am wondering if there is an issue in reading the ADC data from the ADC buffer. Regardless of continuous or single conversion mode, I would suggest to use the "Group Memory Threshold Interrupt" to read the data. For example, there are channels in your usecase. You can set up the threshold to 4. An interrupt or DMA request will be generated after 4 conversion data is accumulated in the buffer. Then, you can use CPU or DMA to read 4 data. It takes time for the data to reach the buffer after the completion of the conversion. You need to make sure that the data is in the buffer before you read. "Group Memory Threshold Interrupt" is a reliable way to read the data.

    Thanks and regards,

    Zhaohong
  • I have saw some suggestions about DMA transmission in this forum proposed by you.It seems a little complicated.I will try next time when it is convinient.However,I want figure out how the results save into results memory.Can you give some thread ?Just like the problem 2 above.Thanks a lots.
  • You do not need to use DMA in this case. However, I recommend you to use the group memory threshold interrupt to read the ADC data. Please refer to the TRM for more details.

    Thanks and regards,

    Zhaohong