Page 1 of 1

qspi multiple devices

Posted: Fri Sep 17, 2010 8:28 am
by chrispol
Hi, right now i am using a mcp3201 in queued spi, i would like to add 2 mcp23s08's for more io, do you have to call QSPIInit each time you read a different device?

Re: qspi multiple devices

Posted: Fri Sep 17, 2010 8:34 am
by seulater
no, You will just call QSPIInit once in you initialization part of your code. That set up the SPI.

Re: qspi multiple devices

Posted: Fri Sep 17, 2010 11:19 am
by lgitlitz
If any of the parameters from the QSPI init function change between devices then you will need to call it again... baud rate, word size, automated chip selects. Since you are using two of the same chips to perform the same function then you probably only need to call this again if you are using the peripheral controlled chip selects. If you are controlling your chip selects with GPIO then you will not need to re-init, just manually toggle the CS lines between transfers.

On a side note, if you care about latency of the A/D reading or are reading the A/D at more then 1Khz then I do not suggest use the standard QSPI driver for these types of A/D chips. The proper way to interface with these would be to manually configure the QSPI peripheral to be in continuous mode. This will allow the QSPI to run in a loop without any interrupts or CPU intervention. It will constantly be reading form the A/Ds and storing the data in the queue registers. Then whenever you want an A/D value, a very recent conversion is already waiting for you in the queue and you just need to read the register.

Re: qspi multiple devices

Posted: Fri Sep 17, 2010 11:23 am
by v8dave
You only have to worry about the init of the QSPI if you are using more than 1 device with different settings across different tasks.

I am using the SD card with the filing system and with a touch screen controller so I have to make changes to the SPI so that I could use a criticial section to handle the access to each device and have to init the QSPI each access because both used a different setting.

If you have only the single device or those of the same QSPI settings, you only have it init it once.

Dave...

Re: qspi multiple devices

Posted: Wed Jun 29, 2011 7:16 am
by chrispol
When you do a qspistart how do you select which chip you want then?

Re: qspi multiple devices

Posted: Thu Jun 30, 2011 12:00 am
by yevgenit
Value of QSPI CS signals is determined per queue x by content of related QCRx[QSPI_CS] bit field.
But, Netburner's library has limitation: it allows to set only the same value to all (x=0 to 15) QCRx[ QSPI_CS ] bit fields. See description of function QSPIInit() at qspi.cpp file.

You need to call QSPIInit() with the desired CS argument before first call of QSPIStart(). This value of CS will be used for all future call of QSPIStart() - until you change value of CS with another call of QSPIInit()/
chrispol wrote:When you do a qspistart how do you select which chip you want then?