qspi multiple devices

Discussion to talk about software related topics only.
Post Reply
chrispol
Posts: 30
Joined: Mon Mar 08, 2010 8:46 am

qspi multiple devices

Post 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?
seulater
Posts: 445
Joined: Fri Apr 25, 2008 5:26 am

Re: qspi multiple devices

Post by seulater »

no, You will just call QSPIInit once in you initialization part of your code. That set up the SPI.
User avatar
lgitlitz
Posts: 331
Joined: Wed Apr 23, 2008 11:43 am
Location: San Diego, CA
Contact:

Re: qspi multiple devices

Post 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.
v8dave
Posts: 333
Joined: Thu Dec 31, 2009 8:31 pm

Re: qspi multiple devices

Post 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...
chrispol
Posts: 30
Joined: Mon Mar 08, 2010 8:46 am

Re: qspi multiple devices

Post by chrispol »

When you do a qspistart how do you select which chip you want then?
User avatar
yevgenit
Posts: 84
Joined: Fri Apr 25, 2008 12:47 am
Contact:

Re: qspi multiple devices

Post 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?
Yevgeni Tunik
Embedded/RealTime software engineer
https://www.linkedin.com/in/yevgenitunik/
________________________
Post Reply