Dear Jan,

spi.setmode is used to set one of the 4 SPI modes 0, 1, 2, or 3, e.g. "1 
spi.setmode".

The mode to use depends on the device you want to connect to, and you will find 
it in the datasheet (perhaps not explicitely stated, but the necessary 
information will be there).  Most common is 0.

Peter

> On 9 Jun 2019, at 20:52, Jan Kromhout <krom1...@hotmail.com> wrote:
> 
> Dear Peter
> 
> This is the code I need to model in amForth
> 
> // enable SPI.Master
>  SPI.setDataMode(SPI_MODE0);
>  SPI.setBitOrder(MSBFIRST);
>  SPI.setClockDivider(SPI_CLOCK_DIV4);
>  SPI.begin();
> 
> What to do with
> 
> \ check SPI device datasheet for mode settings
> : spi.setmode ( spi-mode -- )
> spi.mode pin!
> ;
> 
> With kindly regards,
> 
> Jan
> 
> 
> 
> 
> 
> Op 8 jun. 2019, om 20:45 heeft Matthias Trute 
> <mtr...@web.de<mailto:mtr...@web.de>> het volgende geschreven:
> 
> Hi,
> 
> You can also use the following words to avoid c!@spi, which is
> missing from the preassembled package for the Arduino:
> 
> 
> \ send a byte, ignore received byte
> : c!spi ( c -- )
>   SPDR c! ( c addr -- )
> ;
> 
> \ receive a byte, send a dummy one
> : c@spi ( -- c)
>   0 SPDR c! 1 ms SPDR c@
> ;
> 
> SPDR is a constant holding the address of the SPI data register (&78)
> 
> Thanks, I've added some comments to the spi.frt file.
> 
> Matthias
> 
> 
> _______________________________________________
> Amforth-devel mailing list for http://amforth.sf.net/
> Amforth-devel@lists.sourceforge.net<mailto:Amforth-devel@lists.sourceforge.net>
> https://lists.sourceforge.net/lists/listinfo/amforth-devel
> 
> 
> _______________________________________________
> Amforth-devel mailing list for http://amforth.sf.net/
> Amforth-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/amforth-devel



_______________________________________________
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel

Reply via email to