SPI send data

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
rstechnics
Posts: 16
Joined: Mon Oct 29, 2007 12:17 pm
Has thanked: 2 times
Been thanked: 1 time
Contact:

SPI send data

Post by rstechnics »

Hi, after struggling some days with sending bytes from Arduino/ATMEGA328P to a L6470PD steppingmotor driver chip, using the SPI-master component, please your tips how to sort out this function.

An Arduino.INO example for this L6470 chip does work on the same hardware configuration, so this is good.
Want to transfer it to Flowcode to integrate the other I/O logic, but need to get the steppingmotor functions working good first.

Just want to send a few command-bytes for initalisation, followed by Motor-RUN command bytes (also 3 separate bytes) each second.
At our digital Oscilloscope with SPI view, just get a lot of unknown information on screen when doing this in Flowcode, while the Arduino.INO example works fine with steady readable signal views.

How do i transfer 3 or 4 single bytes after eachother, like this initialisation example:
SPI-MASTER1: Enable CS()
SPI-Master1: Sendchar (0x00)
SPI-MASTER1: Disable CS()

SPI-MASTER1: Enable CS()
SPI-Master1: Sendchar (0x18)
SPI-MASTER1: Disable CS()

SPI-MASTER1: Enable CS()
SPI-Master1: Sendchar (0xA0)
SPI-MASTER1: Disable CS()

SPI-MASTER1: Enable CS()
SPI-Master1: Sendchar (0x06)
SPI-MASTER1: Disable CS()

then followed by a while-loop with 1 second delay at the end :
SPI-MASTER1: Enable CS()
SPI-Master1: Sendchar (0x40)
SPI-MASTER1: Disable CS()

SPI-MASTER1: Enable CS()
SPI-Master1: Sendchar (0x00)
SPI-MASTER1: Disable CS()

SPI-MASTER1: Enable CS()
SPI-Master1: Sendchar (0xFF)
SPI-MASTER1: Disable CS()
delay (1000 ms)

I have used SendChar, or is another command better, like SPI-MASTER1: Transaction, SendString or SendByteArray, and how to use it?

Ar the Enable_CS and Disable-CS needed around each byte, or can it be a single Enable/Disable at top and bottom?

What are the best BUS-settings and Prescale options?

Any other tips, or maybe any SPI-component update needed?

Is any Flowcode SPI example available for this kind (or lookalike) of L6470 chips, or a simular other application i can adjust to it?


thanks and regards,
Luuk Aalders
Attachments
Test_Powerstep01_SPI2test.fcfx
(13.98 KiB) Downloaded 145 times
kind regards,
Luuk Aalders

RS Technics BV
for electronics engineering and industrial controls
The Netherlands
www.rstechnics.nl

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: SPI send data

Post by LeighM »

Have a look at pages 38 and 58 of the datasheet.
Looks like you need to enable CS, then send and receive several bytes, then disable CS
The SPI transaction function can be used to send and receive a byte simultaneously

Post Reply