SPI help

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Flouch
Posts: 29
Joined: Thu Oct 18, 2012 10:19 am
Has thanked: 6 times
Been thanked: 1 time
Contact:

SPI help

Post by Flouch »

I just started the SPI Flowcode and I do not understand how to configure the pins: SCLK, MOSI, MISO, SS. IN fact I only have pins and DAC NVM. My goal is simply to write in registers and read SPI register. If someone has an example
cordially

edit i work on the board EB006 i need other Eblock ?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: SPI help

Post by Benj »

Hello,

If you click on View -> Chip in Flowcode then it will provide you with a chip layout.

The SPI component uses the following pins in hardware mode (Flowcode v5).

SCLK - Chip diagram SCK
MOSI - Chip diagram SDO
MISO - Chip diagram SDI
SS - Any free I/O pin.

I would use a LED component or maybe just a output icon set to work in single pin mode to control your slave select output and then the SPI component macros will do all the rest of the work for you.

For software mode (Flowcode v5) you can assign the SPI pins to any general purpose I/O pins.

If you need an example then let me know.

Flouch
Posts: 29
Joined: Thu Oct 18, 2012 10:19 am
Has thanked: 6 times
Been thanked: 1 time
Contact:

Re: SPI help

Post by Flouch »

Hello,

Yes I would like an example because I do not understand everything,
My project is to configure a receiver-transmitter (transmitter).
So I have to configure different register (frequency etc) documentation page 58 below.
http://www.ti.com/lit/ds/symlink/cc2500.pdf
And after I have read some register as signal strength.
For this project I have the card EB006, a PIC16F88 or PIC16F874 (I can buy else) and I also have the card with 8 LEDs. (It's first time i use Flowcode and im alone for this project)

thanks for you're time sorry for my english i'm french

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: SPI help

Post by Benj »

Hello,

Your English is great, please could you tell me which version of Flowcode your using?

Flouch
Posts: 29
Joined: Thu Oct 18, 2012 10:19 am
Has thanked: 6 times
Been thanked: 1 time
Contact:

Re: SPI help

Post by Flouch »

Benj wrote:Hello,

Your English is great, please could you tell me which version of Flowcode your using?
thanks
flowcode student version V5.4.0.0

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: SPI help

Post by Benj »

Hello,

Sorry but the Student / Home version doesn't support the SPI component. Only the Pro or Site license versions will allow you to compile code for this component and the other advanced components.

Flouch
Posts: 29
Joined: Thu Oct 18, 2012 10:19 am
Has thanked: 6 times
Been thanked: 1 time
Contact:

Re: SPI help

Post by Flouch »

Benj wrote:Hello,

Sorry but the Student / Home version doesn't support the SPI component. Only the Pro or Site license versions will allow you to compile code for this component and the other advanced components.
hmm strange i can use SPI in my student version, Can iupdate to the pro version ?
in not student but home version

hmm i just watch on the website i can update for only 25 pounds ? if is right i can do this

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: SPI help

Post by Benj »

Hello,

The SPI component will simulate but when you go to compile to C code the C functions will be missing.

You can upgrade a home license to a pro license by simply paying the difference between the versions. You can do all this via the form on the main Flowcode page.

http://www.matrixmultimedia.com/product ... rm&Var=PIC

Flouch
Posts: 29
Joined: Thu Oct 18, 2012 10:19 am
Has thanked: 6 times
Been thanked: 1 time
Contact:

Re: SPI help

Post by Flouch »

Benj wrote:Hello,

The SPI component will simulate but when you go to compile to C code the C functions will be missing.

You can upgrade a home license to a pro license by simply paying the difference between the versions. You can do all this via the form on the main Flowcode page.

http://www.matrixmultimedia.com/product ... rm&Var=PIC
Ok no problem then i will do for 150 pounds. where i can find discount code ^^ .?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: SPI help

Post by Benj »

Hello,

You simply pop in you old license key when buying the new version and it should work out the correct discount for you.

Let me know and I will put the example together for you.

Flouch
Posts: 29
Joined: Thu Oct 18, 2012 10:19 am
Has thanked: 6 times
Been thanked: 1 time
Contact:

Re: SPI help

Post by Flouch »

Benj wrote:Hello,

You simply pop in you old license key when buying the new version and it should work out the correct discount for you.

Let me know and I will put the example together for you.
i have already done i just uninstal my home version ! now i have the tools.
i'm ready
thanks again to take times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: SPI help

Post by Benj »

Here is a basic example to read an 8-bit DAC.
Attachments
SPI.fcf
(14.5 KiB) Downloaded 448 times

Flouch
Posts: 29
Joined: Thu Oct 18, 2012 10:19 am
Has thanked: 6 times
Been thanked: 1 time
Contact:

Re: SPI help

Post by Flouch »

Benj wrote:Here is a basic example to read an 8-bit DAC.
so with this example i get a char ( so 1byte) and the led is to select the slave right ?
how the slave can know witch register i want to read ?

and i have two pin for the SPI : DAC pin and NVM pin it's like MOSI ans MISO ?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: SPI help

Post by Benj »

Hello,

Yes the LED component is controlling the slave select pin.

The DAC and NVM pins are slave select pins to be used with the DAC and NVM related functions. It's basically an E-block thing and you can ignore these pin connections.

In hardware mode the connections are specified by the chip, the pins are marked on the chip diagram.
SCLK - Chip diagram SCK
MOSI - Chip diagram SDO
MISO - Chip diagram SDI
The slave select (SS) pin is specified by the LED component connections.

In software mode the SPI pins will appear in the connections manager so you can assign them to which ever pin you like.

Hardware / Software mode is selected by going into the EXT_Properties of the SPI component.

For a module like a memory device there should be a datasheet that details the method to read a specific address. My guess is it is something like this.

Enable slave select (switch off LED)
send command byte to read an address (SPI_Send_Char)
send address byte(s) (SPI_Send_Char)
receive the data byte (SPI_Get_Char)
disable the slave select (switch on LED)

For a generic 8-bit DAC you only ever read one address so the code is much simpler.

Enable slave select (switch off LED)
receive the data byte (SPI_Get_Char)
disable the slave select (switch on LED)

Flouch
Posts: 29
Joined: Thu Oct 18, 2012 10:19 am
Has thanked: 6 times
Been thanked: 1 time
Contact:

Re: SPI help

Post by Flouch »

ok so i have understand how to read a register : 1 enable communcation (SS), send witch register we want to read 1byte and finally receive the information in 1 byte.
and i guess to write something in register we do the same like : enable commucation (ss) and we send two byte : 1 for the register other for the information right ?

Thanks you for the tips for the software mode so i don't care about DAC and NVM ?

sorry for so much questions

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: SPI help

Post by Benj »

Ive had a quick look at the datasheet and here is a quick example to read and write registers.
Attachments
SPI-2.fcf
(13.45 KiB) Downloaded 322 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: SPI help

Post by Benj »

Yep DAC and NVM pins can be ignored and the software mode allows for easy configuration.

Let me know how you get on.

Flouch
Posts: 29
Joined: Thu Oct 18, 2012 10:19 am
Has thanked: 6 times
Been thanked: 1 time
Contact:

Re: SPI help

Post by Flouch »

what do you think of the program bellow ? write something with SPI and read the information
Attachments
Flowcode1.fcf
(11.34 KiB) Downloaded 300 times

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: SPI help

Post by Enamul »

That seems fine.
Enamul
University of Nottingham
enamul4mm@gmail.com

Flouch
Posts: 29
Joined: Thu Oct 18, 2012 10:19 am
Has thanked: 6 times
Been thanked: 1 time
Contact:

Re: SPI help

Post by Flouch »

Enamul wrote:That seems fine.
thanks, but i think i got a problem in the board i had develop to isolate the 3.6V and the 5V...

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: SPI help

Post by Enamul »

i think i got a problem in the board i had develop to isolate the 3.6V and the 5V...
Can you please tell what the problem is?
Enamul
University of Nottingham
enamul4mm@gmail.com

Flouch
Posts: 29
Joined: Thu Oct 18, 2012 10:19 am
Has thanked: 6 times
Been thanked: 1 time
Contact:

Re: SPI help

Post by Flouch »

Enamul wrote:
i think i got a problem in the board i had develop to isolate the 3.6V and the 5V...
Can you please tell what the problem is?
i think i have a problem with my schematic
http://i46.tinypic.com/2j4x53t.png
maybe is not good or my resistance pull-up to low (2Kohms) when i just plut my board to the led all the led are light i don't know why

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: SPI help

Post by Enamul »

maybe is not good or my resistance pull-up to low (2Kohms)
You can try with 4.7K pull up resistor.
Enamul
University of Nottingham
enamul4mm@gmail.com

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: SPI help

Post by Enamul »

Hi
Another issue you can check..idle state of the clock pulse (SCK) and in which edge clock works. Sometimes in SPI it causes the problem. You will get those information in the property of the component.
Enamul
University of Nottingham
enamul4mm@gmail.com

Flouch
Posts: 29
Joined: Thu Oct 18, 2012 10:19 am
Has thanked: 6 times
Been thanked: 1 time
Contact:

Re: SPI help

Post by Flouch »

Enamul wrote:Hi
Another issue you can check..idle state of the clock pulse (SCK) and in which edge clock works. Sometimes in SPI it causes the problem. You will get those information in the property of the component.
I am looking if the clocks are synchronized (same frequency)?

thanks again for help me but at this time i don't know if it's my program of my board...
Last edited by Flouch on Sat Dec 01, 2012 11:41 am, edited 1 time in total.

Post Reply