I am workign with ADS1246 data converter. Powering up the chip and using SPI bus I am able to read A2D data. I assume the defult register values allow the converstion take place and I do get reasonable conversition. I would like to write to SYS0 register, so that sampling rate is set to 160sps. I am having trouble with RREG and WREG commands though. I am using Table 22's commands, however the wrting or reading part when it comes to registers don't work. I have tried different vlaues, yet, when I read SYS0 register back I get 0. Your feedback and comments will be much appreciated. My code follows.
Thanks,
Hamid
spi.write(0x43); // first command: write register SYS0 - address 03h
spi.write(0x00); // second command byte: 0000_nnnn (n is number bytes -1)
spi.write(0x05); // sys0: gain = 1 and 160sps
SYS0_reg1 = spi.write(0x23); // read register SYS0 - address 03h
SYS0_reg2 = spi.write(0x00);
pc.printf("sys0 regiter1 = 0x%X \n\r", SYS0_reg1);
pc.printf("sys0 regiter2 = 0x%X \n\r", SYS0_reg2);
bcs_reg = spi.write(0x00);
spi.write(0x20); // read register BCS - address 00h
bcs_reg = spi.write(0x00);
pc.printf(" BCS contains = 0x%X \n\r", bcs_reg);
while(1)
{
START1 = 1;
Va2d = Vcalculation();
pc.printf(" V= %f \r\n", Va2d);
START1 = 0;
//wait(1);
}
}