This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

MCB1700 Lpc1768 ports P0.23, P0.24

I have the following problem, P0.23 and P0.24 are Select as AD0.0 and AD0.1, when I read of the channels, they have the same Voltage as AD0.2 on P0.25, but nothing stands in the schematics of
P0.23 and P0.24, they are not connected or am I wrong?

Parents Reply Children
  • /*Initialisiere AD0, Channel 0 */
    void adcInit0_0(void) {

    LPC_PINCON->PINSEL1 |= ( 1 << 14); /* P0.23 is AD0.0 */

    LPC_ADC->ADCR = ( 1 << 0) | /* select AD0.0 pin*/ ( 4 << 8) | /* ADC clock is 25MHz/5*/ ( 1 << 21); /* enable ADC*/ }

    /*Lesen des aktuellen DAC Wertes an ADC0.0*/
    float adcRead0_0(void) {

    LPC_ADC->ADCR |= ( 1 << 24); /*start conversion*/

    while (!(LPC_ADC->ADDR0 & ( 1UL << 31))); /*Wait for Conversion end*/
    dac_Vin = LPC_ADC->ADDR0 >> 4 ; /*Store converted value*/
    DACin = adc_Ain*3.3/4096.0; /*Umrechnung bzw. Formatierung des ADC-Wertes in Wert an DAC*/
    /*(ADC-Wert * Vref / 4096 diskrete Werte (12 Bit Converter)*/

    return(DACin);
    }

  • 1) You didn't read the posting instructions so very carefully. You forgot to pick up how to post source code.

    2) DAC != ADC.

    3) Try to use just a single language for variable names and comments. English is normally a good choice. Helps if you want help. And many companies have english as official language. Besides - much easier when you cut/paste code from projects and examples you find on the net.

    4) You read out a value into variable dac_Vin. Then you compute DACin based on adc_Ain, before returning DACin. So DACin doesn't seem to be based on any value you read out from the ADC, but from a variable you don't show us where it gets its value from.

  • I checked the source code again with debuging, and its correct!

    I work on a MCB1760 evaluation board, and on the schematic pdf of MCB1760, the P0.23 and P0.24 are not connected to anything, but if I have the pins as described above as AD0.0 and AD0.1 select, they get the same voltage as AD0.2 select???

  • "I checked the source code again with debuging, and its correct!"

    Are you saying that the code you checked is not the same as the code you posted?

    Because the code you posted assigns the ADC value to one variable (dac_Vin). But uses a completely different variable (adc_Ain) for converting from ADC ticks into voltage.

    If you never assign a new value to adc_Ain - how can you then use it to represent the new ADC value?

  • I checked the source code with debuging, after i correct the source code!

    and so must it be the connecting that are not be writen in the schematics!

    etc.:

    I work on a MCB1760 evaluation board, and on the schematic pdf of MCB1760, the P0.23 and P0.24 are not connected to anything, but if I have the pins as described above as AD0.0 and AD0.1 select, they get the same voltage as AD0.2 select???

  • Don't try to measure voltages for unconnected pins.

    When used as digital inputs, they normally have a weak pull-up enabled (unless you disable the pull-up or switches it to pull-down).

    But what holds the pins at a known state when you change them to ADC inputs, if you haven't connected any external signals to the pins?

  • I checked the source code with debuging, after i correct the source code!

    and so must it be the connecting that are not be writen in the schematics!

    Nonsense!