Bit Banging SPI on 13192-Sard board

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Bit Banging SPI on 13192-Sard board

5,537件の閲覧回数
adevenport
Contributor I
Hello all.
 
I am relatively new to all of this and have never interfaced with SPI.  I have an Analog Devices 360 degree inclinometer (ADIS16203) that I would like to interface with the 13192-SARD board from the Zigbee Eval Kit.  The microcontroller on the board is a MC9S08GT60.  From what I understand, the microcontroller has an SPI bus, but it is being occupied with the MC13192 radio.
 
The data sheet for the ADIS16203 mentions bit banging a SPI interface.  From my preliminary internet research, I need 3 output pins (CS/, DOUT, SCLK) and 1 input pin (DIN) available to do this.  Fortunately there are 13 pins available on a header (J105) that I can control in software, but am not entirely sure what to do from here.
 
Are there any good resources about this topic for a newbie?
 
Thanks for any help!
ラベル(1)
0 件の賞賛
返信
4 返答(返信)

1,251件の閲覧回数
bigmac
Specialist III
Hello,
 
In a general sense, it is usually possible for the SPI peripheral to be shared between multiple external devices, provided no one device requires continuous data transfer - an unusual requirement.  However, for the board you are using, since external access to the SPI pins is not provided, I agree it will probably be easier to bit-bang using pins to which external access is provided.
 
In general, the SPI code will have to be specifically tailored to suit the particular external device.  For the ADIS16203, I would make the following observations -
 
  1. The external device is the slave, and the MCU the master, and the SCLK signal will originate from the MCU.  This is the more typical arrangement.
  2. The requirement of CPOL = 1 means that the SCLK signal will idle at the high state.  The external device will change the state at its Dout (or MISO) pin after the negative edge of the clock, and read the state at its Din (or MOSI) pin at the positive edge of the clock.  For compatibility, the MOSI output from the MCU should update its output after generating the negative clock edge, and read the returned data at MISO after generating the positive clock edge.
  3. The requirement of CPHA = 1 means that the MS bit of the data at MOSI will be presented after the first negative clock edge, and that the bit state prior to this edge is not relevant.  I would suggest that you examine the transmission format waveforms for the hardware SPI peripheral, because this is what you are attempting to emulate.
  4. Since the inclinometer device requires a data length of 16 bits, it would probably be more efficient for your SPI code to also handle 16 bits at a time. (A hardware SPI would actually handle only 8 bits at a time).
  5. The inclinometer is capable of receiving the next command word while it simultaneously provides output of the response to the previous command word.  If you wish to take advantage of this, your bit bang code would need to be a single routine that simultaneously caters for both data output and data input.  I would normally do this anyway, but the code examples you may observe in application notes, etc. may not.
Will you be programming in assembler or C?  The shift operations required are more complex and convoluted to program in C because there is not direct access to the carry flag of the MCU - well, that's my opinion - perhaps others will disagree.
 
Regards,
Mac
 
0 件の賞賛
返信

1,251件の閲覧回数
bigmac
Specialist III
Hello,
 
I have attached my attempt to write a software SPI combined send and receive function in C.  Each transaction is for a 16 bit word, and should be compatible with a slave device that requires CPOL = 1 and CPHA = 1.  I have not shown the necessary I/O initialisation code.  This code will be significantly slower than a similar function written in assembly code.
 
Regards,
Mac
 
0 件の賞賛
返信

1,251件の閲覧回数
mjcoury
Contributor I
if you search this board and the internet for "SOFTWARE SPI" you should find what you are looking for
0 件の賞賛
返信

1,251件の閲覧回数
moradi
Contributor I
hello all,
I want to use ADIS16203 in a control board and i have a question,
can i use atmega128(8 bit microcontroller of avr family) to spi interface with this sensor?
regards
0 件の賞賛
返信