Announcement

Collapse
No announcement yet.

SM700 ADC using external Vref channels

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • SM700 ADC using external Vref channels

    I recently had some problems using "virtual channels" the analog inputs with the SM700.

    According to the reference manual, you can get the ADC to reference against one of 2 external reference. When I tried this however I was unable to get the ADC to read anything other than the default VCC channel.

    After some digging through spec sheets I was able to come up with the following solution to manually setup the ADC via it's control register. I hope this comes in useful to others.


    ADC_BASE_HI = 0x8000
    ADC_BASE_LO = 0xD018 #ADC_CONTROL REGISTER

    ADCREF_ON = 0x11 #enables VREF1 channel
    ADCREF_OFF = 0x01 #Reverts to default VCC ref channel

    poke(ADC_BASE_HI, ADC_BASE_LO, 1, ADCREF_OFF) #switch to VCC ref channel

    #Vbatt = (1.2 * 4096) / batVolt
    batVolt = readAdc(8) #read against VCC channel

    poke(ADC_BASE_HI, ADC_BASE_LO, 1, ADCREF_ON) #switch to VREF1 ref channel
    v1 = readAdc(0) #read against external VREF1
X