Send SPI signals to the PWM pins

Hello all,

Is there any easy software way that i can send the SPI signals (SS,MOSI and SCLK) to some of the PWM pins in Arduino mega 2560? The idea is that those pins will be connected to the pins of an external device which i want to connect on the SPI. I'm also using an Ethernet Shield so those SPI signals should also exist on their predefined locations at the same time or else i guess the Ethernet Shield would stop working.

If this is not feasible then would it be ok if i externally connected the default SPI pins to the PWM pins i want to use?

Is there any easy software way that i can send the SPI signals (SS,MOSI and SCLK) to some of the PWM pins in Arduino mega 2560? The idea is that those pins will be connected to the pins of an external device which i want to connect on the SPI.

That makes little sense. SPI has nothing to do with PWM and PMW has nothing to do with SPI. Why not use the SPI pins to control the (mystery) external device? SPI is a bus, that means that the SCK, MOSI ns MISO pis are shared by all the devices on the bus. There is a chip select signal for each device that differentiates the devices on the bus. So, you would have to provide a separate chip select signal* to the mystery device.

*separate and different than the Ethernet shield.

groundFungus:
That makes little sense. SPI has nothing to do with PWM and PMW has nothing to do with SPI. Why not use the SPI pins to control the (mystery) external device? SPI is a bus, that means that the SCK, MOSI ns MISO pis are shared by all the devices on the bus. There is a chip select signal for each device that differentiates the devices on the bus. So, you would have to provide a separate chip select signal* to the mystery device.

*separate and different than the Ethernet shield.

Well the device is a DAC (dac8551). The thing is that i made a pcb with that DAC based on the idea that i will place it on top of the Ethernet shield. I didn't think it right though and i made the pcb to connect to 3 of the Ethernet shield's pins that end up in Arduino PWM pins 9,10 and 11 (on the pcb they are also connected to the DAC pins corresponding to SCLK, MOSI, SS). So i'm asking if i can avoid remaking the pcb. What if i bend the 3 pins connecting to the Arduino PWM and connect them externally to the SPI instead? Would that cause any malfunctions to the Ethernet shield, or are they not used by it anyway?

Draw a schematic of what you've done. Your description isn't making sense to me. If you mean you used pin 11 for the DAC then no, you can't get around that. Pins 11, 12, and 13 are hardware SPI, if you use SPI then you use them. They're hard wired so to speak. Pin 10 you can repurpose maybe but it MUST be an output.

You could do a complete redesign of the ethernet shield and put it on software SPI but that will get clunky really quick if there's anything else the code has to be able to do.

I'm using an Arduino Mega 2560 so the SPI pins are actually 50,51,52 and 53. Here's an image to help you see what im talking about.

It shows how the DAC connects to the Ethernet shield (and so on the same pins of the Arduino). What i'm actually saying is if i can use wires to connect the SPI pins (51,52 and 53) on those pins and thus to the DAC pins. I can bend the 3 Ethernet shield pins so there is not a connection between the Arduino and the Ethernet shield on those 3 pins if that's an issue. So if i use wires to connect the DAC on the SPI but also on those 3 pins of the Ethernet shield (while placing the pcb on top of it) will it be fine?

Let me put it as simple as i can. I can use wires to connect the DAC directly on the SPI. Would it be a problem if pins 9,10 and 11 were also connected on the SPI but not used to transfer any signal? I simply want to place the PCB on those pins just to have it steady.

Its like this:

SPI======DAC
|
|
pins

I think I see. Set pins 9, 10, and 11 as input.

The SPI pins are also broken out on a little header in the middle of the board. That’s where the Ethernet shield picks them up. That way it can work with UNO or Mega either one.

Doesn't pin 10 need to be an output for hardware SPI to work as a master?

groundFungus:
Doesn’t pin 10 need to be an output for hardware SPI to work as a master?

On an UNO, but on a Mega it’s pin 53.

If they’re also connected to 9, 10, and 11 by mistake then as long as 9, 10, and 11 remain inputs they hopefully won’t affect the circuit.