News:

;) This forum is the property of Proton software developers

Main Menu

SPI MODE 1

Started by Francesco55, Jul 16, 2024, 11:55 AM

Previous topic - Next topic

Francesco55

Hi everyone,
I am Francesco from Italy, i have this issue;
I have to use ADS1220, this converter communicates via SPI port in mode 1, can you kindly tell me what this mode corresponds to in Positron's SPI configuration:
Thank in advance
Regards

Stephen Moss

I had hoped someone that has doen this would have replied by now, as they have not from a quick search it looks like Mode 1 means data is read out to the slave on the rising edge of the clock and read in from the Slave on the falling edge.
However, there is nothing to indicate that Mode 1 determienes if the data is transmitted LSB for or not, nor does it appear to determine the clock idle state.
From the Device data sheet it appears that data is shifted in/out MSB first, and the clock idles low, thus from that I would conclude that you need...
MsbFirst_L & MsbPost_L

But I am not entirly sure that is correct as I have only performed SPI communication using the PIC's MSSP module, not the compilers bit-bashed software commands for two reasons...
  • In hardware the MSSP transmission/reception of the current byte should not be interrupted by an device interrupt, whereas that could occure with software based transmission.
  • When using the software option it appears that data read and write occure in separate operations, whereas often SPI data is transmited and recieved simultaneously, thus the two data pins (SDI and SDO).

So the software option should work in sutuations where you only need to send data to the slave device, or send a command to the salve and then it sends data, but would not where simultaneous transmit and recieve are required as the first byte of data transmitted by the slave would be lost while data is written to it.

Francesco55

Hi Stephen,
what you wrote is correct, following your suggestions everything works now, thanks for the help.
' ADS1220 Setting ____________________________________________
  ADC_CS1 = CSEnable
  SHOut SPI_DataOut, SCLK, MsbFirst_L, [Reg_RST]
  SHOut SPI_DataOut, SCLK, MsbFirst_L, [$43, $81, $00, $58, $00] ' Write Register 0, 1, 2, 3
  ADC_CS1 = CSDisable

This is part of my code.

Francesco