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.

RM48L952ZWT GPIO ADC question

Other Parts Discussed in Thread: HALCOGEN, RM48L952

Several months ago, I posted a question regarding the number of available GPIOs. From what is stated below, we can used the ADC inputs as digital inputs:

 

14 are ADC which can be set to convert automatically in the background,  have their conversion result compared to a threshold register that is user programmable and resolved to '1' or '0' based on this comparison

 

I spend the whole afternoon with the ADC, but could not figure out yet how to achieve such functionality. Your help would be more than appreciated!

  • You can choose one group to be continuously converted with up to 3 channels (only 3 threshold interrupts hooked up to VIM), and program a threshold for each of these 3 channels. Then the ADC will generate an interrupt if the conversion for a channel is lower than or greater-than-or-equal-to the programmed threshold.

    This functionality is not supported by HALCoGen and needs to be configured directly.

    Alternatively, you can setup a continuous conversion group and then just check the most significant bit of each result to determine if the input is above or below half scale.
  • Hello Bob,

    Thanks for the hint. I used the second option, using the MSB. Just in case somebody wants to use that feature, two things to take in account:

    1) For the ADC to run non stop (even if the FIFO is full), the Ignore Overrun must be set manually (not supported by HalCoGen). I added the following at the end of adcInit(): adcREG1->GxMODECR[2U] |= (uint32)0x00000010U;

    2) To read the latest conversion and ensure each channels is always at the same location within the ADC RAM, the Group's memory must be setup to have the same amount of words as the number of selected channels in the group.

    The following while(1) loop, on the RM48L952 HDK provides good results.

    hetREG1->DOUT = (uint32) ((*(adc1_data + 0) & 0x800) <<  6) //ADC1IN0 MSB shifted to N2HET1[17], top left LED on HDK

                    | (uint32) ((*(adc1_data + 1) & 0x800) << 20)       //ADC1IN1 MSB shifted to N2HET1[31], top LED on HDK

                    | (uint32) ((*(adc1_data + 2) & 0x800) >> 11)       //ADC1IN2 MSB shifted to N2HET1[00], top right LED on HDK

                    | (uint32) ((*(adc1_data + 3) & 0x800) << 16)       //ADC1IN3 MSB shifted to N2HET1[27], left LED on HDK

                    | (uint32) ((*(adc1_data + 4) & 0x800) >>  6)       //ADC1IN4 MSB shifted to N2HET1[05], right LED on HDK

                    | (uint32) ((*(adc1_data + 5) & 0x800) << 18)       //ADC1IN5 MSB shifted to N2HET1[29], bottom left LED on HDK

                    | (uint32) ((*(adc1_data + 6) & 0x800) <<  7)       //ADC1IN6 MSB shifted to N2HET1[18], bottom LED on HDK

                    | (uint32) ((*(adc1_data + 7) & 0x800) << 14);      //ADC1IN7 MSB shifted to N2HET1[25], bottom right LED on HDK

    Latency <= 14ms. 

    Thanks

  • Thank you for posting your results for the benefit of the rest of us.