Content originally posted in LPCWare by rw_ on Mon Apr 14 06:05:17 MST 2014
I got it working *some* ...then, after fooling around with the code trying to get it to read two bytes (it kept reading only one byte, no matter how many bytes I told it to read in the parameter structure), it "decided" to quit addressing the bus properly. I started seeing 0x23 instead of 0x90 as the slave address being asserted on the bus, to which, obviously, the slave would not ACK. I have no idea why it started doing it. I reset everything, rebooted Windoze and Keil and cycled power enough times and eventually shelved it after testing the DS7505 with an external I2C master 'pod,' which worked fine *and* read both temp sensor bytes.
As for the PLL, the ROM API has a PLL configuration feature, too. I was simply defining USE_ROM_API "just in case" something else wanted it in the code/library, even though I grep'd it. There are enough minor issues combined to make one wonder whether or not it works, but, to be fair, the documentation does say that the polled I2C is intended to be for trivial use whereas the interrupt-driven ROM API for I2C is intended to be (assumed) production ready. Maybe my next step is to modify the code for interrupt use? I can't imagine anything more trivial than reading two bytes from a 7505...
I eventually discovered my own error(s) in terms of initial usage. I was calling the i2c_setup function from the SystemInit function, which is called before main. Naturally, Keil was 'secretly' initializing the .bss section somewhere after SystemInit and before main and trashing my global handle. Doh! Slow firing synapses recalled Kevin Wells telling me to not use any global data in SystemInit...but somehow that fired too slowly until after debugging showed that as soon as I entered main, my global handle was zeroed. I pulled the code out of SystemInit, called it from main and things got significantly better until the 'weird' addressing snafu.
A quick look at your code looks like I need to use the "i2c_master_tx_rx_poll" function instead of the 'transmit' followed by a 'receive' call, which is what I have been doing. Of course, who knows what will happen before I figure out why 0x90 (or 0x91) somehow magically become 0x23...inducted bit flipping from local noise on my LA leads?
I'll try it and let you know...