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