0
\$\begingroup\$

Please excuse my ignorance. I need your advise and clarification on something. I'm using the 18f4550 and I'm a little curious about the communication protocols. I am not using the USB features. It has 1-EUSART, and 1 (SPI/I2C) comm. My question is, the EUSART and SPI seem to share pin26 (on the 40pdip). I need to use both. Is it normal for 2 comm protocols to share a pin and just toggle the config of that pin throughout the program?

Are the SPI devices on that line going to be confused at the UART data they see on it, and vice versa? How likely is it they could react to some signal from the other protocol? Or is it good practice never to dual-use such a pin and spec a chip with 2 separate protocol pin allocations?

Thank you.

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

It looks like the UART transmit line and the SPI data out line share a pin on that part. That happens sometimes. Some of the newer PICs have alternate pins for some of the peripherals, or have the remappable pin feature. The 18F4550 is a rather old part.

Trying to share the pin sounds like a lot more trouble than it's worth. Fortunately, SPI is very easy to do in firmware if you're the master. If this PIC needs to be a SPI slave, then you probably should use a different PIC. Otherwise, just do the master function in firmware. SPI is very simple, so that is easy to do. Since it's synchronous and you own the clock, it doesn't matter if the processor occasionally goes off to a interrupt routine or something.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ That sounds exactly right. I'll add that the 4550 is odd because of the USB support, and if the OP isn't married to it he might opt for a more general purpose ucontroller \$\endgroup\$ Commented Oct 4, 2012 at 21:17
  • \$\begingroup\$ Thank you guys. I'm certainly not married to the 4550. I just had several of them and they had the port volume for my project. I'm using a variety of inputs (~14) using ADC and D-I/O. as far as outputs, I need to port to an LCD but was planning to use a serial variety. Also, need room to add a wireless module (but that can be whatever serial is available). Using 1-wire DS18b20 temp sensor so that's 1 data port. SPI rtc (DS3234). And a pH sensor (UART). \$\endgroup\$
    – Mark
    Commented Oct 4, 2012 at 21:47
  • \$\begingroup\$ Looks like the 18f4620/18f46K20 may be a better choice, huh? I think that does all I need and avoids the pinout problem, plus I get more chip (speed, memory, etc.) \$\endgroup\$
    – Mark
    Commented Oct 4, 2012 at 22:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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