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.

TPS65217 MUX failing to switch output

Other Parts Discussed in Thread: TPS65217

Hello,

I wanted to ask what are the possible reasons why TPS65217 would fail to switch MUX output. Or maybe I'm just failing to do something. Problem happens with BeagleBoeard Black (TPS65217C + AM335x), acording to schematics it should have TPS65217B but after reading CHIPID reg I get 0xE2, which should mean it is TPS65217C revision 1.2. Battery is added to original BBB - everything about it is working.

Test code for reading ADC and changing MUX position:

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <linux/i2c-dev.h>

#define MUX_IN      0x05

int main(int argc, char* argv[]) {
    int     hndl_i2c, hndl_adc, i, adc_val;
    char    *filename_i2c = "/dev/i2c-0",
            *filename_adc = "/sys/devices/ocp.3/helper.15/AIN7",
            instr[2],
            dummy;
    int addr = 0x24;        // The I2C address of the ADC
    if ((hndl_i2c = open(filename_i2c, O_RDWR)) < 0) {
        /* ERROR HANDLING: you can check errno to see what went wrong */
        perror("Failed to open the i2c bus");
    }
    if ((hndl_adc = open(filename_adc, O_RDONLY)) < 0) {
        /* ERROR HANDLING: you can check errno to see what went wrong */
        perror("Failed to open the adc");
    }
    if (ioctl(hndl_i2c, I2C_SLAVE_FORCE, addr) < 0) {
        perror("Failed to acquire bus access and/or talk to slave - ");
        /* ERROR HANDLING; you can check errno to see what went wrong */
    }
    i = MUX_IN;
    instr[0] = 0x09;
    instr[1] = i;
    if (write(hndl_i2c, instr, 2) != 2) {
        perror("Failed to write to the i2c bus - ");
    }
    if (write(hndl_i2c, instr, 1) != 1) {
        perror("Failed to write to the i2c bus - ");
    }
    if (read(hndl_i2c, &dummy, 1) != 1) {
        perror("Failed to write to the i2c bus - ");
    }
    while(i) {
        char    str_val[25];
        usleep(10000);   //lets wait 10mS to switch multiplexer and settle volta$
        lseek(hndl_adc, 0, SEEK_SET);
        read(hndl_adc, &str_val, 25);
        sscanf(str_val, "%d", &adc_val);
        printf("ADC value at MUX pos(%d) = %d\r\n", dummy, adc_val);
        i--;
        instr[1] = i;
        if (write(hndl_i2c, instr, 2) != 2) {
            perror("Failed to write to the i2c bus - ");
        }
        if (write(hndl_i2c, instr, 1) != 1) {
            perror("Failed to write to the i2c bus - ");
        }
        if (read(hndl_i2c, &dummy, 1) != 1) {
            perror("Failed to write to the i2c bus - ");
        }
    }
    close(hndl_i2c);
    close(hndl_adc);
}

program output:

ADC value at MUX pos(5) = 1689
ADC value at MUX pos(4) = 1689
ADC value at MUX pos(3) = 1689
ADC value at MUX pos(2) = 1689
ADC value at MUX pos(1) = 1689

Also checked MUX output with osciloscope, no changes in it during probing, only constant voltage of 1.86V.

Where can be problem that I can't get MUX output working?

Laurynas

  • Laurynas,

    Just a few question to clarify what you are trying to accomplish:

    Are you trying to see the values of the different Mux output opitons (i.e 001 – VBAT

    010 – VSYS

    011 – VTS

    100 – VICHARGE

    101 – MUX_IN (external input) )?

    Or are you varying the external input on MUX_IN?

    The output value you are seeing, is it the MUX_IN external input voltage?

    If you are trying to see other voltages like VSYS an VTS, I don’t see where in your code you change intrs[1] from 0x05 (MUX_IN option) to another option. If you can help clarify this, I can be of more assistance.

     

    Janice

  • Hello,

    I'm trying to read all different outputs, and MUX_IN is connected to Supply voltage over divider if I recall correctly (don't have schematics atm next to me).

    And  intrs[1] value I change in line 47, also if you check, I'm printing pos(x) from value I receive after reading MUX pos after setting it.

    Basically I'm setting mux, reading it's value, reading ADC, and then printing received mux position and ADC value.

    Laurynas

  • Hello.

    Looks like it was my mistake. I found wrong schematics, and in correct one MUX_OUT is left unconnected.

    will need to make some adjustments, then will try again.