SPI handling sample code (AVR)

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hello, All!

    Where it's possible to get some simple source code in C controlling SPI
communication? I need to understand master/slave init, transfer, etc. I've
checked datasheet for my MCU but code presented there seems to be too easy
    Thanks in advance.

With best regards, Roman Mashak.  E-mail: snipped-for-privacy@tusur.ru

Re: SPI handling sample code (AVR)

Quoted text here. Click to load it

SPI is very simple, usually all you have to do is to write the byte you want
to send into a register, wait for a xfer done bit to become set, and read
the received data from a register.

The difficulties are in the periphals you want to control and making sure
you have selected the right SPI mode from the numerous modes there are
(clock phase, clock edge select, msb/lsb first etc). Some devices support
full duplex, some don't.

So, SPI in itself is very easy, but some devices can have many registers to
setup before they can be used.


Site Timeline