Ack!! AT89S8253 (8051 microcontroller problem)

Jan 25, 2018 11 Replies

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.


You're just not holding your tongue right. ;-P

Even then you could have a dry joint. I've had perfectly sound looking solder joints have zero conduction. If you haven't already, I'd suggest doing continuity testing pin to pin.

Sylvia.

Have you carefully checked the CS line timing?

Thanks, - Win

U know the datasheet specifies a 2 MHz clock freq _max_ @ 5 volts, yeah?

Try pull ups on P1.... seems to ring a bell with me from way way back. I did lots of designs with 98c52 then moved up to /LS8252/3

This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

If I'm not misunderstanding the OP's post it seems like he's trying to run the chip at 20 times its specified max clock freq for its maximum supported sampling freq of 100ksps.

If the input to the ADC channel is e.g. a full-scale low-frequency sine wave, if the sourcing impedance of the signal source is slightly lower than the sink impedance and the S&H RC time constant is long compared with the clock frequency, then the S&H will rapidly integrate the in-out charge imbalance right to the positive rail and it ain't never gonna come back down.

Which is what seems to be happening. Slow down Speed Racer what's your hurry

Actually, with an 11 MHz crystal, I don't think it's even possible to over-clock the ADC. It takes several dozen instruction cycles per read. But of course, I S-L-O-W-E-D down the bit-bang anyway with a bunch of NOP's.... to absolutely no avail.

The problem turned out to be a couple things: Which... I'm too embarrassed to admit. :) But here's a hint: Thanks Sylvia!

Anyway, working now!!!

We've all done that more than once!

Oh, right, it's an 8051. I've been spoiled by RISC uPs.

Grin, yup. Worse are intermittent cold solder joints. The hardest thing about trouble shooting is assuming you know what's wrong, and then chasing yourself down some blind rabbit hole.

George H.

r-clock the ADC. It takes several dozen instruction cycles per read. But of course, I S-L-O-W-E-D down the bit-bang anyway with a bunch of NOP's.... to absolutely no avail.

pfff, the problems are always in the hardware, never in the software :D

Bye Jack

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required