Recent

Author Topic: [CLOSED] SPI implementation  (Read 1421 times)

julkas

  • Guest
[CLOSED] SPI implementation
« on: September 21, 2019, 03:51:50 pm »
« Last Edit: December 16, 2019, 02:40:02 pm by julkas »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11351
  • FPC developer.
Re: SPI implementation
« Reply #1 on: September 21, 2019, 04:10:16 pm »
Mostly it is only putting a byte in a register and then idling on a bit till it is sent and then reading the value of the register back?

Afaik Arduino has no SPI fifos or DMA, so it should be pretty simple.
« Last Edit: September 21, 2019, 04:14:59 pm by marcov »

ccrause

  • Hero Member
  • *****
  • Posts: 843
Re: SPI implementation
« Reply #2 on: September 21, 2019, 05:47:50 pm »
Any SPI https://en.wikipedia.org/wiki/Serial_Peripheral_Interface impl. in Free Pascal (Arduino Uno R3)?
I found this - https://wiki.freepascal.org/AVR_Embedded_Tutorial_-_SPI/de.
As marcov said, it is not too complicated. The code in the tutorial seems good, so no reason not to start with that as your base. Copy the tutorial code into a unit and start testing - all code snippets up to:
Code: Pascal  [Select][+][-]
  1. end.
  You need to figure out which SPI port(s) and pins needs to be used for your chip (the tutorial configuration is for atmega328p) and configure the variables and constants in the interface section.  You also have to know the specific SPI configuration compatible with your slave device and configure the SPR register, although the values in the tutorial seems typical.

If you struggle, show your code and ask for more advice.

julkas

  • Guest
Re: SPI implementation
« Reply #3 on: September 21, 2019, 06:08:50 pm »
Thanks @markov, @ccrause.
To be continued...

 

TinyPortal © 2005-2018