Page 1 of 2

SPI help

Posted: Fri Nov 30, 2012 11:16 am
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 ?

Re: SPI help

Posted: Fri Nov 30, 2012 12:58 pm
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.

Re: SPI help

Posted: Fri Nov 30, 2012 1:15 pm
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

Re: SPI help

Posted: Fri Nov 30, 2012 2:27 pm
by Benj
Hello,

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

Re: SPI help

Posted: Fri Nov 30, 2012 2:44 pm
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

Re: SPI help

Posted: Fri Nov 30, 2012 2:49 pm
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.

Re: SPI help

Posted: Fri Nov 30, 2012 3:08 pm
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

Re: SPI help

Posted: Fri Nov 30, 2012 3:21 pm
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

Re: SPI help

Posted: Fri Nov 30, 2012 3:28 pm
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 ^^ .?

Re: SPI help

Posted: Fri Nov 30, 2012 4:27 pm
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.

Re: SPI help

Posted: Fri Nov 30, 2012 4:34 pm
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

Re: SPI help

Posted: Fri Nov 30, 2012 4:56 pm
by Benj
Here is a basic example to read an 8-bit DAC.

Re: SPI help

Posted: Fri Nov 30, 2012 5:06 pm
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 ?

Re: SPI help

Posted: Fri Nov 30, 2012 5:14 pm
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)

Re: SPI help

Posted: Fri Nov 30, 2012 5:23 pm
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

Re: SPI help

Posted: Fri Nov 30, 2012 5:27 pm
by Benj
Ive had a quick look at the datasheet and here is a quick example to read and write registers.

Re: SPI help

Posted: Fri Nov 30, 2012 5:28 pm
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.

Re: SPI help

Posted: Fri Nov 30, 2012 5:33 pm
by Flouch
what do you think of the program bellow ? write something with SPI and read the information

Re: SPI help

Posted: Fri Nov 30, 2012 6:02 pm
by Enamul
That seems fine.

Re: SPI help

Posted: Fri Nov 30, 2012 8:03 pm
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...

Re: SPI help

Posted: Fri Nov 30, 2012 8:04 pm
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?

Re: SPI help

Posted: Fri Nov 30, 2012 8:07 pm
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

Re: SPI help

Posted: Fri Nov 30, 2012 8:23 pm
by Enamul
maybe is not good or my resistance pull-up to low (2Kohms)
You can try with 4.7K pull up resistor.

Re: SPI help

Posted: Fri Nov 30, 2012 8:26 pm
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.

Re: SPI help

Posted: Fri Nov 30, 2012 8:29 pm
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...