# What's up with my 74HC4052?

I am using a TI 74HC4052E to multiplex a TTL UART on a Microchip PIC32MX695F512 microcontroller.

The expected behavior is for the TX and RX signals to pass through the switches unaffected; sadly this is not what is happening.

I am working from a dev board and the PIC has proper bypass caps and all that jazz, and the UART is configured properly - it works correctly when directly connected to an FTDI USB->Serial adapter.

Here is a simplified schematic:

simulate this circuit – Schematic created using CircuitLab

Pins RB15/RB1 are configured as buffered outputs, not open-drain. Analog functionality on those pins is disabled. I have no pullups/pulldowns on B0/B1 outputs.

A look at the peripheral registers:

TRISB = 01111111 1111101 (0x7FFD)
ODCB = 00000000 00000000 (0x0000)


Edit: I noticed that the U5TX pin is RB14 and as shown, is configured as input. I am pretty sure enabling the peripheral overrides the TRIS bits, but I went ahead and forced it to digital output. I also made sure the analog functionality on that pin was disabled. Neither of these changes rectified the situation.

The program loops though the following: selects A/B0, outputs data, selects A1/B1, outputs data.

When I put CH2 of the 'scope on the B0 output pin (pin 1), this is what I see:
CH1 (Yellow) - Probing pin 3 input
CH2 (Blue) - Probing B0 output

The signal is incorrectly inverted. You can see when the switch turns off as well, indicated by the (slowly) decaying signal, which doesn't look right.

Probing B1 (pin 5) results in the following:

CH1 (Yellow) - Probing pin 3 input
CH2 (Blue) - Probing B1 output

Now the signal polarity is correct, but I see still that goofy looking decay. I really don't think it should take ~400µs to switch off/on.

When I manually select A0/B0 by connecting the controls signals directly to GND, the B0 signal is no longer inverted, but then again, it is no longer switching, so it is hard to say if this means anything.

I tried using another '4052 and got the same results. The chip has good power and ground connections - I don't think it is being powered through any internal protection diodes or something weird like that. I have a feeling the PIC GPIO pins are somehow influencing this behavior through the S0/S1 select lines, although I don't know why that would be the case.

I read over the datasheet a couple times but I must be missing something that would explain what I'm seeing.

What am I doing wrong here?

• Do you have any pullup/pulldown resistors on B0 and B1? If yes: what value?
– user36113
Jun 17 '14 at 4:27
• Question updated. RB1/RB15 indeed configured as outputs and no pulls on B0/B1. Jun 17 '14 at 4:41
• You should have B0, B1, A0, A1 pulled up through 10K (4 resistors, 1 for each). I think the nasty charge curve you're seeing is the mux switching the line you're probing to high-impedance. Jun 17 '14 at 5:46
• Is it definitely a HC version and not HCT? Jun 17 '14 at 7:39
• At the risk of inducing another face-palm, you need to look more closely at your first picture. You are being misled by the fact that when the output is not selected it decays to zero despite the fact that the PIC output is high. Other than an artifact caused by the exact timing of your select signal causing an apparent short high pulse at the beginning of the data burst, the data is NOT inverted. Look closely. Jun 17 '14 at 20:55