Go Down

Topic: USART SPI not working (Read 230 times) previous topic - next topic

danny92

Mar 19, 2018, 12:59 am Last Edit: Mar 19, 2018, 01:10 am by danny92
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: http://www.gammon.com.au/forum/?id=10892, 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

ard_newbie


There is no Library to use USART in SPI mode, so you have no other choice than learning how works an SPI transfer.

Then write your own sketch to transfer bytes between USART0 and USART1 in SPI mode on a single board. Come back with your own code if you encounter issues (code between code tags).

No one will write your code for you, unless you go to the "Gigs and collaborations" section of this forum and open your wallet.

srnet

I have a program that logs packets received on a LoRa radio to an SD card.

Both are SPI devices, and the program works just fine, even on a humble Pro Mini.
http://www.50dollarsat.info/
http://www.loratracker.uk/

Go Up