2
\$\begingroup\$

I have PIC18F4455 connected to spark core wifi chip. I send data from PIC18F4455 to the spark core by using UART. The problem is the output data of pic18f4455 equals to 5v, and the spark core accepts only 3.3V. My question is there any way to convert this data to 3.3v ( softwar in the PIC18F4455 or hardware) ?

Ali

\$\endgroup\$
4
  • \$\begingroup\$ The search term you're looking for is "level translator". \$\endgroup\$ – Matt Young Aug 18 '15 at 3:13
  • \$\begingroup\$ what do you mean? \$\endgroup\$ – Micheal Aug 18 '15 at 3:17
  • \$\begingroup\$ A "level translator" is a device or module that converts signals from one voltage to another. A bi directional one will do both directions. \$\endgroup\$ – Passerby Aug 18 '15 at 3:20
  • \$\begingroup\$ thanks Matt. Do I have to buy this device? is there any wat to make the pic18 transmit the data in 3.3v level \$\endgroup\$ – Micheal Aug 18 '15 at 3:26
10
\$\begingroup\$

UART is unidirectional, so you can use unidirectional level converter like this: Unidirectional level converter

Alternatively, you may use 5v to 3.3v bidirectional level converter. For each wire, you need to build the converter like this one:

Bidirectional Level Converter

Since UART has two wires (TX and RX), we need two set of the converter. There is sparkfun board has 4 pins on the high side and 4 pins on the low side. Since it is bidirectional, it works for UART, I2C, etc.

\$\endgroup\$
1
  • \$\begingroup\$ Even though the question is rather stale and reported duplicate, I want to point out a problem in the BSS138 bidirectional converter above. The gate has to be connected to the 3.3V rail, not to the 3.3V signal. Ref: cdn.sparkfun.com/tutorialimages/BD-LogicLevelConverter/… \$\endgroup\$ – earGrowth Aug 1 '19 at 14:33
2
\$\begingroup\$

It would have been nice if you had provided some datasheet.

Most modern microcontrollers have some or all pins being 5V tolerant even if they are being supplied from a 3.3V source. What this means, is that you can send 5V into the GPIO and it will be ok.

Sometimes you just have to spend the extra work to find the answer (and it's not that hard either).

First thing you need is the datasheet.

enter image description here

enter image description here

Great now I know what the microcontroller is. But does it have 5V tolerant IO ? I don't know. Lets find the datasheet.

enter image description here

First page (bottom left corner).

enter image description here

So almost all are 5V tolerant. Which ones do you need ? I don't know. You can look it up yourself now.

Hopefully you can see, that a bit of Google goes a long way. Even if you search wrong, if you have a good sense of what you would like to do, reading through the pages, can sometimes direct you in the right direct.

Derp If I had read slower, I would have seen that the second screenshot was the same summary (although not complete datasheet), so I could have figured out that it was 5V tolerant by the second picture. I would still need the full datasheet to find out which pins are 5V tolerant and which ones aren't.

\$\endgroup\$
1
  • \$\begingroup\$ Being 5V tolerant, means that it safely takes 5V, but not sources. It will not be able to drive a pin over Vcc, which is 3.3V. Will PIC understand 3.3V as a HI level? \$\endgroup\$ – zmechanic May 25 '19 at 9:01
1
\$\begingroup\$

You need employ voltage level shifters. I prefer 74LVC125, 74HCT125 ICs.

http://www.ti.com/lsds/ti/logic/voltage-level-translation-overview.page

Hope this helps,,,,

\$\endgroup\$
0
\$\begingroup\$

You can use a logic level converter to translate the 3.3 volt signal to 5 volts and the other way around. You can do this with two MOSFETs (2n7000, for example) and 4 10k resistors.

You can find an example schematic here.

\$\endgroup\$
0
\$\begingroup\$

Try to use resistor divider for MCU's Tx. In the most cases Rx line of 5V transmitter (your MCU) will accept 3.3V signal level.

\$\endgroup\$
1
  • \$\begingroup\$ Only when Vin High is 0.6 * Vcc or lower. \$\endgroup\$ – Passerby Aug 18 '15 at 7:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.