This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
resources:eval:user-guides:spi [13 May 2022 17:41] – m valerie hamilton | resources:eval:user-guides:spi [18 May 2022 13:59] (current) – final edit valerie hamilton | ||
---|---|---|---|
Line 8: | Line 8: | ||
=== SPI Modes === | === SPI Modes === | ||
- | SPI has 4 modes that it operates in. The CPOL bit sets the clocks polarity during the idle state. The CPHA bit selects the clock phase. For mode 0 and mode 1, the idle clock state is low. For mode 2 and mode 3, the idle clock state is high. CPOL and CPHA bits decide on which edge is the data sampled and shifted. The Mode Table below demonstrates SPI modes. The AD5758 (and all other generics listed in the INFO) can be used in either mode 1 or mode 2. | + | SPI has 4 modes that it operates in. The CPOL bit sets the clocks polarity during the idle state. The CPHA bit selects the clock phase. For mode 0 and mode 1, the idle clock state is low. For mode 2 and mode 3, the idle clock state is high. The CPOL and CPHA bits decide on which edge the data is sampled and shifted. The Mode Table below demonstrates SPI modes. The AD5758 (and all other generics listed in the INFO) can be used in either mode 1 or mode 2. |
===SPI Mode Table=== | ===SPI Mode Table=== | ||
Line 16: | Line 16: | ||
| 2 | 1 | | 2 | 1 | ||
| 3 | 1 | | 3 | 1 | ||
+ | |||
=== SPI Cyclic Redundancy Check (CRC)=== | === SPI Cyclic Redundancy Check (CRC)=== | ||
To verify that data has been received correctly in noisy environments, | To verify that data has been received correctly in noisy environments, | ||
*< | *< | ||
- | This sequence is added to the end of the data-word, and 32 bits are sent to the AD5758 before taking SYNC high. | + | This sequence is added to the end of the 24 bit data-word, and 32 bits are sent to the AD5758 before taking SYNC high. |
If the CRC check is valid, the data is written to | If the CRC check is valid, the data is written to | ||
the selected register. If the CRC check fails, the data is ignored and | the selected register. If the CRC check fails, the data is ignored and | ||
- | the SPI_CRC_ERR bit is set. The SPI CRC feature can be used for both the | + | the SPI_CRC_ERR bit is set along with the fault pin being asserted. The SPI CRC feature can be used for both the |
transmission and receipt of data packets. The CRC is enabled by default so the user must | transmission and receipt of data packets. The CRC is enabled by default so the user must | ||
supply a frame of exactly 32 bits wide that contains the 24 data bits | supply a frame of exactly 32 bits wide that contains the 24 data bits | ||
- | and 8-bit CRC for the first SPI write. To disable the CRC (Bit SPI_CRC_EN) it is recommended to do this after the calibration memory refresh step. | + | and 8-bit CRC for the first SPI write. To disable the CRC (Bit 0 SPI_CRC_EN |
+ | |||
===Writing to a Register=== | ===Writing to a Register=== | ||
Line 38: | Line 40: | ||
| Slip Bit | Address Bits | Register Address | | Slip Bit | Address Bits | Register Address | ||
- | With SPI CRC enabled (default state), the input shift register is 32 bits wide. Data is loaded into the device MSB first as a 32-bit word under the control of a serial clock input, SCLK. Data is clocked in on the falling edge of SCLK. If CRC is disabled, the serial interface is reduced to 24 bits; a 32-bit frame is still accepted but the last 8 bits are ignored. \\ | + | With CRC enabled (default state), the input shift register is 32 bits wide. Data is loaded into the device MSB first, under the control of a serial clock input, SCLK. Data is clocked in on the falling edge of SCLK. If CRC is disabled, the serial interface is reduced to 24 bits; a 32-bit frame is still accepted but the last 8 bits are ignored. \\ |
===Reading a Register=== | ===Reading a Register=== | ||
Line 52: | Line 54: | ||
Figures 1 and 2 show the first and second software reset key writes. The first write of 0x8815FAA4 can be decoded as | Figures 1 and 2 show the first and second software reset key writes. The first write of 0x8815FAA4 can be decoded as | ||
- | ^ | + | |
- | | | + | ^ |
- | | | + | | |
- | Slip Bit = 1, Address Bits = 00, | + | | |
+ | |||
+ | For the second write the data has changed to 0xFA51 and the CRC changed to 0x31. | ||
Line 61: | Line 65: | ||
<fc # | <fc # | ||
<fc # | <fc # | ||
- | <fc # | + | <fc # |
- | <fc # | + | <fc # |
- | \\ | + | **In the following examples the software driver is configured for SPI mode 1 and the CRC is enabled.**\\ |
{{ : | {{ : | ||
Line 76: | Line 79: | ||
</ | </ | ||
- | Figure 3 shows a readback of the default state of the digital diagnostic results register (Address 0x14). There are 2 SPI frames visible in the scope plot. Figures 4 and 5 show the first and second SPI frames respectively. The first being the readback command and the second shows the NOP command along with the readback data on SDO. The readback data 0x942000 | + | Figure 3 shows a readback of the default state of the digital diagnostic results register (Address 0x14) before the calibration memory has been refreshed. There are 2 SPI frames visible in the scope plot. Figures 4 and 5 show the first and second SPI frames respectively. The first being the readback command |
{{ : | {{ : | ||
Line 84: | Line 87: | ||
- | {{ : | + | {{ : |
<WRAP centeralign> | <WRAP centeralign> | ||
- | //Figure 4 Two Stage Readback command - first frame// | + | //Figure 4 Two Stage Readback command - first frame write 0x93001478// |
</ | </ | ||
{{ : | {{ : | ||
<WRAP centeralign> | <WRAP centeralign> | ||
- | //Figure 5 Two Stage Readback command - second frame including SDO data// | + | //Figure 5 Two Stage Readback command - second frame write 0x8000000B (including SDO data 0x94A0001A)// |
</ | </ | ||
=== Calibration Memory Refresh === | === Calibration Memory Refresh === | ||
- | After performing a software or hardware reset the next write **must** be a calibration memory refresh. The refresh is performed by writing the key 0xFCBA to the key register (address 0x08). | + | After performing a software or hardware reset the next write **must** be a calibration memory refresh. The refresh is performed by writing the key 0xFCBA to the key register (address 0x08). |
- | + | ||
- | + | ||
- | {{ : | + | |
- | <WRAP centeralign> | + | |
- | //Figure 6 Calibration Memory Refresh Write// | + | |
- | </ | + | |
===Disabling CRC=== | ===Disabling CRC=== | ||
- | After performing a calibration refresh the CRC can be disabled if desired. The command to disable the CRC is Figure 4 shows the SPI write to clear the reset occurred bit. The SPI write to disable the CRC is 0x50005CB7 | + | After performing a calibration refresh the CRC can be disabled if desired. The command to disable the CRC is Figure 4 shows the SPI write to clear the reset occurred bit. The SPI write to disable the CRC is 0x50005CB7. |
- | + | ||
- | + | ||
- | {{ : | + | |
- | <WRAP centeralign> | + | |
- | //Figure 8: SPI frame to disable the CRC// | + | |
- | </ | + | |
===Clearing Reset Occurred=== | ===Clearing Reset Occurred=== | ||
- | After performing a calibration refresh the device can now be configured as required. The reset occurred bit (Bit 13) in the digital diagnostic results register (Address 0x14) is a logic high and should be cleared. To clear the bit a " | + | After performing a calibration refresh the device can now be configured as required. The reset occurred bit (Bit 13) in the digital diagnostic results register (Address 0x14) is a logic high and should be cleared. To clear the bit a " |
- | {{ : | ||
- | <WRAP centeralign> | ||
- | //Figure 7: RESET_OCCURED Bit Being Cleared// | ||
- | </ | ||
- | |||
- | |||
- | |||
- | |||
- | {{ : | ||
- | <WRAP centeralign> | ||
- | //Figure 6: RESET_OCCURED Bit Being Cleared// | ||
- | </ | ||
- | |||
- | {{ : | ||
- | <WRAP centeralign> | ||
- | //Figure 7: RESET_OCCURED Bit Being Cleared// | ||
- | </ | ||