Flex and SPI

Forum related to the FLEX boards

Moderator: paolo.gai

Locked
desmomito
Newbie
Posts: 27
Joined: Wed Mar 05, 2008 4:03 pm

Flex and SPI

Post by desmomito » Mon Jun 30, 2008 9:28 am

Hi,
I\'ve seen the possibility to connect the Flex, using the PIC18, to the USB in order to log data, send commands and so on. I\'ve found that really ineresting and that could be really interesting for my application. For this reasons I have two questions about that :

1) In order to program the PIC18 I\'ve to set the jumpers correctly has written in Flex docs ? Nothing more ?

2) I don\'t have a demo board how can I set up the SPI connections between the PIC18 and dsPIC ? Which pins I have to use ? Do I need any resitors or circuit adapter between the two MCU ?

Thanks a lot,
Pasquale.

paolo.gai
Administrator
Posts: 875
Joined: Thu Dec 07, 2006 12:11 pm

Re:Flex and SPI

Post by paolo.gai » Mon Jun 30, 2008 1:20 pm

Hi Pasquale!

Yes... use the jumper settings as described in the FLEX docs...

For the SPI connection, please use a Demo Daughter Board, or connect the pins directly using the instructions found at http://www.evidence.eu.com/content/view/250/266/

(And once you have done that, could you please update the Wiki with any missing information you found?)

bye

PJ

desmomito
Newbie
Posts: 27
Joined: Wed Mar 05, 2008 4:03 pm

Re:Flex and SPI

Post by desmomito » Tue Jul 01, 2008 10:38 am

Thank you,
I did not understand the pictures until I\'ve got inside the SPI peripherical peripheral. ;)

- From the pictures it seems that I just need to take care about the PIC18 (3.3V - JP9) power supply and wire the dsPIC and PIC18. I don\'t need any resistor or something, right?

- I\'ve seen the application for Windows that write data using USB to the PIC18. Could please tell me how did you write that application ? Which driver did you use ?

- There is also something wrong in the picture where it\'s shown the connection for the SPI. As I\'ve seen from the schemes of the Flex Full there are not PIC18\'s pins on the CON6 (64 pins). Is it right ?

As soon as I do my application I will be glad to write the missing things to the wiki.

Thank you,
Pasquale.

paolo.gai
Administrator
Posts: 875
Joined: Thu Dec 07, 2006 12:11 pm

Re:Flex and SPI

Post by paolo.gai » Mon Jul 07, 2008 2:53 pm

Hi Pasquale...

- no resistors in that case...
- we wil release the application soon, hopefully before the Microchip Masters
- the CON6 contains some pins which come from the PIC18... which are basically linked to the programming part of the dsPIC and to the spi...

Ciao,

PJ

daniele.caprini
Newbie
Posts: 17
Joined: Thu Sep 04, 2008 4:30 pm

Re:Flex and SPI

Post by daniele.caprini » Wed Sep 24, 2008 11:26 am

Hi Guys, I have a question for anybody who has worked with spi on flex.
I have connected the con6\'s pins of the flex with my spi device and I have read the protocol documentation of dspic33, the reference manual cap 18, and also my spi device protocol documentation.
Now, has someone some code about this implementation to look at?

You\'d help me a lot.
Thank you in advance

Daniele

paolo.gai
Administrator
Posts: 875
Joined: Thu Dec 07, 2006 12:11 pm

Re:Flex and SPI

Post by paolo.gai » Wed Sep 24, 2008 11:41 am

Yes... there are a few functions about SPI on Flex in the ERIKA Enterprise source code. Just look into:

ee/pkg/board/ee_flex/inc/ee_board.h
and
ee/pkg/board/ee_flex/inc/ee_board.c

Ciao!

PJ

daniele.caprini
Newbie
Posts: 17
Joined: Thu Sep 04, 2008 4:30 pm

Re:Flex and SPI

Post by daniele.caprini » Wed Sep 24, 2008 1:16 pm

Thank you.

Daniele

nino
Newbie
Posts: 15
Joined: Thu Sep 04, 2008 1:14 pm

Re:Flex and SPI

Post by nino » Thu Sep 25, 2008 9:04 am

Also the ZigBee \"Wireless Communication using FLEX and ERIKA Enterprise Basic\" application notes has ee_radio_spi.c and ee_radio_spi.h for spi init and communication.

Nino

daniele.caprini
Newbie
Posts: 17
Joined: Thu Sep 04, 2008 4:30 pm

Re:Flex and SPI

Post by daniele.caprini » Thu Sep 25, 2008 9:31 am

Many thankx Nino.
These functions are a good point of start for me.

Stay tuned for help me.

Daniele

daniele.caprini
Newbie
Posts: 17
Joined: Thu Sep 04, 2008 4:30 pm

Re:Flex and SPI

Post by daniele.caprini » Thu Sep 25, 2008 10:24 am

Hi, my ideas aren\'t clear.
Can I connect directly con6\'s pins 21,41,43,44 in order to use spi1?or must I use the multibus board+multibus module?

Thx
Daniele

paolo.gai
Administrator
Posts: 875
Joined: Thu Dec 07, 2006 12:11 pm

Re:Flex and SPI

Post by paolo.gai » Thu Sep 25, 2008 11:31 am

you can connect directly the SPI pi, but be careful because there is no resistors between the CPU and your hardware...

PJ

daniele.caprini
Newbie
Posts: 17
Joined: Thu Sep 04, 2008 4:30 pm

Re:Flex and SPI

Post by daniele.caprini » Wed Oct 01, 2008 10:11 am

Hi guys, I\'m always here to asking some tips about spi.
I have to setup a comunication sequence between flex (the master) and DCB500( yamar production, the slave).
I have only to send data from Master to Slave; the Master starts the transmission process by lowering pin SS and sending the command byte 41h. The following bytes are data bytes to be transmitted. After the last data byte is sent to
the slave, the Master raises and lowers the SS pin and than sends the command byte A1h. Than the master raises the SS pin.
I rising and lowering SS pin after my data sequence but, on oscilloscope I see SS1 rise and lower much earlier than i expect.
I think the problem is the time requied to send data from SPI1BUF to shift register and from shift register to SDO.
In effect before sends another data byte I check if the previous data byte is moved from SPI1TXB to SR, but it\'s not send yet on SDO pin.
It looks like that the command on SS pin is always 2 byte in advance.
Actually I haven\'t connect the slave, I try to create the sequence on oscilloscope with the right start & end times.

Image & code attach: http://orfeo.unipv.it/daniele/image-code.zip

Many Thanks

Crazy Daniele

daniele.caprini
Newbie
Posts: 17
Joined: Thu Sep 04, 2008 4:30 pm

Re:Flex and SPI

Post by daniele.caprini » Wed Oct 01, 2008 11:31 am

Now it seems work well.
If after every byte sended I read a byte throught this istruction:

while(!SPI1STATbits.SPIRBF);
SPI1STATbits.SPIROV = 0;
read_byte = SPI1BUF;

the pin SS go high when I want (!!!

Is good this method?

daniele.caprini
Newbie
Posts: 17
Joined: Thu Sep 04, 2008 4:30 pm

Another question about SPI

Post by daniele.caprini » Thu Oct 16, 2008 6:03 pm

Hi guys, I have another question for all.
Is there some command to set spi communication in LSB first or I must reverse my data before send it?
I see that data-out is send MSB first and data-in received LSB first, but I need to send data LSB first.

Thankyou very much.

/Daniele


EDIT: The problem is resolved, I reverse my byte before send it.

Locked