Author Topic: ARM9260 SPI chip select question  (Read 2590 times)

0 Members and 1 Guest are viewing this topic.

Offline SuperJeepTopic starter

  • Contributor
  • Posts: 28
  • Country: ca
ARM9260 SPI chip select question
« on: September 26, 2013, 02:19:18 pm »
This may be a very chip specific question but hopefully some one has had experience with it.

The AT91SAM9260 arm uC I am using has two SPI peripherals with 4 chip select lines each (spi1_npcs0-3, and spi0_npcs0-3). my question is: Can I setup the spi0 peripheral (clock and MOSI lines) but use the spi1 peripheral's chip select line? (the custom board is wired this way so I cant get around it). Would it be too "hack" to simply initialize the CS pin of the slave and pull it low manually before transmission? Its controlling a DAC which doesnt need data very often.

I guess what I am looking for is -> Are the spi peripherals of this chip completely independent of one another on a hardware level and therefore not allowing me to use the clock lines of one with the chip select of another?

I think my best option is to manually setup the CS pin as an output and pull it low when I want to transmit (unless I am missing something)

EDIT: I just realized that what I am asking is for people to go through a huge datasheet and find information for me. I am going to attempt to solve my own problem and will post an update in case anyone needs this information in the future. As of now, it seems the peripherals are independent and manually pulling the CS pin low seems to be the best solution.
« Last Edit: September 26, 2013, 03:15:46 pm by SuperJeep »
 

Offline senso

  • Frequent Contributor
  • **
  • Posts: 951
  • Country: pt
    • My AVR tutorials
Re: ARM9260 SPI chip select question
« Reply #1 on: September 26, 2013, 06:18:44 pm »
There is NO problem what so ever in using GPIO to control the CS lines, at least in the smaller atmegas, it works a treat, but be aware of one thing, in the atmegas, if the hardware CS pin of the SPI interface is used as an input pin it can set the SPI into slave mode.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: ARM9260 SPI chip select question
« Reply #2 on: September 26, 2013, 08:11:11 pm »
Yes, it can be done.

It is very easy to do it as a master.

For a slave, you will need to have an interrupt on that pin. In the corresponding isr, turn on the spi module.
================================
https://dannyelectronics.wordpress.com/
 

Offline Harvs

  • Super Contributor
  • ***
  • Posts: 1202
  • Country: au
Re: ARM9260 SPI chip select question
« Reply #3 on: September 27, 2013, 01:21:04 am »
Only other thing I can think of to consider (having not gone through the datasheet) is if you are using DMA, and the peripheral requires the CS pin to be cycled each transaction (like most? DACs) then on some mcus they can be configured to bring the CS line high between words automatically.

This is only of significance really if your using an external DAC for waveform generation with DMA, or automatically sampling from an ADC.  So probably of no significance in your case.
 

Offline SuperJeepTopic starter

  • Contributor
  • Posts: 28
  • Country: ca
Re: ARM9260 SPI chip select question
« Reply #4 on: September 27, 2013, 03:35:55 pm »
Thanks everyone for the advice and feedback. I actually ended up running into a bigger issue. I was unable to get the SPCK to run at all. Even after trying multiple ways and register settings for initializing the SPI peripheral it wouldnt work(made sure the pins were initialised to the peripheral and not gpio).
I have resorted to using an interrupt based off of another timer in my code to manually generate the SPI clock and program the entire DAC by "bit-banging" each pin.
One quick question. Is this entirely frowned upon? I only need to program this DAC a few times and there is a decent amount of time between these moments. so I could technically intialise the interrupt routine to generate the spi signals when needed and then disable it once the DAC is programmed.
 

Offline TheDirty

  • Frequent Contributor
  • **
  • Posts: 440
  • Country: ca
Re: ARM9260 SPI chip select question
« Reply #5 on: September 27, 2013, 05:47:45 pm »
Bit banging SPI is very common and simple.  Not frowned on at all.
Mark Higgins
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: ARM9260 SPI chip select question
« Reply #6 on: September 27, 2013, 06:11:37 pm »
Quote
I have resorted to using an interrupt based off of another timer in my code to manually generate the SPI clock and program the entire DAC by "bit-banging" each pin.

No reason to use a timer interrupt for that, unless you are truly emulating a hardware spi - ie., loading up the data register and the timer module will send the char by itself.

Bit-banging is OK but tends to be considerably slower than hardware spi.
================================
https://dannyelectronics.wordpress.com/
 

Offline SuperJeepTopic starter

  • Contributor
  • Posts: 28
  • Country: ca
Re: ARM9260 SPI chip select question
« Reply #7 on: September 30, 2013, 01:42:56 pm »
Thanks for the replies. I'm glad to hear that it, It makes sense that the only major benefit for using the peripheral is reduced cpu overhead and cleaner code but I think my case makes this fine seeing as I am only programming a dac to set a reference voltage output so I am not emulating an analog waveform or anything (speed isnt an issue).

Thanks again for the help everyone
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf