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.

use ADC pin to look like gio

Other Parts Discussed in Thread: HALCOGEN, TMS570LS1227

Hi,

I am using the TMS570LS1227, CCS6 and halcogen 4.1

 

I have an input line coming in to AD1IN[12].  I need to monitor it like it is gio, it will either be high or low.  I was thinking I could read in the data and if it is above a threshold call it a 1, if not call it 0.  However, I can't seem to get a valid ADC reading.  Can someone verify my halcogen setup and code?

Halcogen:

Enable ADC1 driver

I thought I would need to mux the pin as it looks like it is shared with AD2IN[12] , but I don't see it on the pinmux tab.

 

Under the ADC1 Tab:

ADC1 group event:

fifo size - 1

rising edge

checked enable pin 12

ADC1 Group 1 tab:

fifo size - 1

rising edge

software trigger

enable pin 12

 

my code to start a reading and get the result is

void main(void)
{
/* USER CODE BEGIN (3) */

    uint32 ch_count=0;
    uint32 id    =0;
    uint32 value =0;
	adcInit();
	adcData_t data;
	adcStartConversion(adcREG1, 1);

	 while((adcIsConversionComplete(adcREG1,adcGROUP1))==0);


	ch_count = adcGetData(adcREG1, 1, &data);

	id    = data.id;
	value = data.value;
/* USER CODE END */

 

but it always returns 0 regardless of the input for the id and value, but ch_count is 1.  I tried following the Halcogen example. 

 

Any idea what I am doing wrong?

  • Not clear what you're doing wrong.

    There is no pinmuxing for the AD inputs ... just shared channels between the two ADCs.
    So that part is right.

    And you are trying to kick off a conversion - which is correct.  There is no LVCMOS input buffer on the A/D pin.  You have to perform a conversion like you are trying to do and then compare the result to a threshold to resolve the analog in to a  0 or a 1.   the only help we have in hardware for this magnitude compare w. interrupt capability (x3 of them) so you can let the ADC check a channel for 1 or 0 based on your chosen threshold and interrupt the CPU when the comparison matches.   

    But looks like you're not going so far as to try making that work.

    It looks like you are just having trouble w. a simple ADC conversion.

    Now, the channel ID is optional and does not show up in the result unless you enable it.

    There is a checkbox in HalCoGen to enable this ... it is on the tab for each ADC conversion group, in the 'ADCx YYYY Group Configuration' group of options (top of the tab) and the option is "Enable Channel ID in Conversion Results".

    If you don't have this box checked, then I would expect your ID to return 0.

    Ok so what I don't understand is whether you think the value is correct or not.  Looks like you might just be thrown off a bit by the channel ID being 0 and if this is the case and you haven't enabled the channel ID in the result then everything may be ok.  Let me know.

  • Hi,

    Thanks for your response.  I don't have the enable channel id box checked, so returning 0 is fine.  What seems to not be working is that the value field is always reading 0, even when a non-zero signal is coming in.

     

    Eventually I will add in the interrupt capability you mentioned, but right now I am just trying  to see that I can see a change in reading.

    [EDIT] I added the enable channel id, and the channel id is getting set correctly.  I have tried two different pins but always see a value of 0 from both.

  • Hi David,

    Ok that sounds like progress.  Is bit 31 of the conversion result set?  That would indicate that you are reading an empty result from the FIFO.   But I doubt this if you are getting the channel ID.

    Obviously you need to check not only the input voltage but also the ADREFHI, ADREFLO, ADVCC, ADVSS pins.

    You can also try the example that ships w. ADC for HalCoGen:  example_adcDisplay.c since you are at this point really just trying to get the ADC to convert.

  • Is bit 31 of the conversion result set?

    DS - If you are referring to the adc-GxINTFLG, for group 1 it is reading 9, so no, bit 31 is not set.

     

    I will check the voltages you indicated.  I followed the example you referenced in setting up halcogen and my code.  I am using a custom board at the moment, I have an HDK I will see if I can get it working there.

     

    Thanks

  • Looks like it is a wiring issue.  ADREFLO was tied to 3.3v.  Once they ground it I will try again.

     

    Thanks