For the life of me, I don't know what is wrong. And I'm on a deadline.
I'm trying to bit-bang an 8-CH, 12-bit A/D converter. It's a Microchip MCP3208, attached to port-1.
Although it is connected to the uPC's SPI port, I'm not using that feature because my development tools don't support it natively, and I don't have ti me to mess with workarounds. The SPI's functions are disabled (SRF's), so Port-1 should just behave as normal port. Right?
Well, I'm getting "4095" returned on every read (i.e., the max value, 2^12) - which is definitely incorrect. I have fiddled with the ADC timing ad na useam.
Do I need to put a pull-up on Port-1? On the scope, it does sort of look like I'm having trouble holding the pin high on Chip Select and MISO and the other two really aren't pretty and sha rp either (for no obvious reason)? I'm clocking at 2x with 11.0592 xtal.
I should note: My board is laid out EXACTLY the same as my (tried and true!) development b oard (which does not exhibit this issue), and on which, my code works perfe ctly, even when swapping physical processor chips. I did trace an unrelate d to issue to my programmer/ISP not tri-stating after a programming session , which is a manageable annoyance.. but only barely.
So, I just have to say... WTF?
Honestly, after two days (on and off) and a lot of external time pressures for delivery, this is really starting to piss me off.
I must be doing something truly stupid. (Wouldn't be the first time!) Anybody got any ideas, or ever run into an ADC problem like this before? It's not like this is cutting-edge hardware.
It's a lot of code, so I really have few options other than to get this pie ce of it working via bit-bang. Too much low-level optimized code in other areas to switch to some different development tool with better SPI support (and really, no guarantee that would work anyway, since I don't even know w hat's wrong.)
The hand-soldering and PCB look good.
Aargh.!! I guess I'm just venting. This is not an ADC I'm all that familiar with.