Forums

Ack!! AT89S8253 (8051 microcontroller problem)

Started by mpm January 24, 2018
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 time 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 nauseam.

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 sharp 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 board (which does not exhibit this issue), and on which, my code works perfectly, even when swapping physical processor chips.  I did trace an unrelated 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 piece 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 what'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.
mpm wrote:

> 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
On 25/01/2018 1:23 PM, mpm wrote:

> The hand-soldering and PCB look good.
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.
mpm wrote...
> > I'm trying to bit-bang an 8-CH, 12-bit A/D converter. > It's a Microchip MCP3208, attached to port-1.
Have you carefully checked the CS line timing? -- Thanks, - Win
On 01/24/2018 09:23 PM, mpm wrote:
> 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 time 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 nauseam. > > 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 sharp either (for no obvious reason)? I'm clocking at 2x with 11.0592 xtal.
U know the datasheet specifies a 2 MHz clock freq _max_ @ 5 volts, yeah?
> > It's a lot of code, so I really have few options other than to get this piece 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 what'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. >
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
On 01/25/2018 06:45 AM, TTman wrote:
> >> >> It's a lot of code, so I really have few options other than to get >> this piece 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 what'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. >> > 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
On Thursday, January 25, 2018 at 9:17:18 AM UTC-5, bitrex wrote:
> 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.
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!!!
On 26-Jan-18 11:26 AM, mpm wrote:
> On Thursday, January 25, 2018 at 9:17:18 AM UTC-5, bitrex wrote: >> 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. > > 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!
On 01/25/2018 10:26 PM, mpm wrote:
> On Thursday, January 25, 2018 at 9:17:18 AM UTC-5, bitrex wrote: >> 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. > > 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!!! >
Oh, right, it's an 8051. I've been spoiled by RISC uPs.