USART SPI not working

Greetings,

I need an alternative SPI interface running in master mode, because when I'm using an SD shield to read or write a file to or from an SD card, I can't use anything else connected to that interface, otherwise the SD card fails to initialize.

I'm trying to use a code that I've seen on a thread started by D. Lloyd, and based on the code I've seen on Gammon Forum by Nick Gammon: Gammon Forum : Electronics : Microprocessors : SPI - Serial Peripheral Interface - for Arduino, SPI from the USART ... an alternative is the title of the message I've based my example code on.

I'm trying to communicate using TX2 (MOSI) only, to an MCP4922 DAC, but the DAC value remains 0.0 V after running the code.

I don't understand how the spi mode is set, neither the CS pin (should it be done manually, like I'm doing in the code?). Is the clock pin defined correctly?

Anyone has successfully implemented an SPI interface using USART?
I really need to use external DACs and ADCs.

Regards,
Daniel

Due_USART1_SPI_Master.ino (6.13 KB)

Can't help with that but the below sounds a bit strange.

I need an alternative SPI interface running in master mode, because when I'm using an SD shield to read or write a file to or from an SD card, I can't use anything else connected to that interface, otherwise the SD card fails to initialize.

Please show the code for that? And post links to used 3rd party libraries if needed.

Hi sterretje,

When I use both a SD card to read an wav file and an external DAC (MCP4922) to convert the from the wav file, the DAC only reproduces the signal for a second or less, if I define the CS pin of the DAC "manually" the SD card won't initialize. I'm using the pin 4 as CS for the SD and pin 10 or 52 for the DAC, or 22 if defined "manually".

I'm not using any third party libraries, only SD and SPI.

I've attached the code to reproduce an WAV file using an external DAC. The code doesn't work.

Regards,
Daniel

DumpAudioFile3_optimized_fast_external_dac.ino (11.6 KB)