SPI handling sample code (AVR)

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

Reply to
Roman Mashak
Loading thread data ...

SPI

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.

Jeroen

Reply to
Jeroen

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.