This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Hercules SPI - Changing Data Formats on Same SPI Bus

Hello All,

I have several peripheral SPI slaves on the same bus - some are 16 bit, some 8 bit (one is 24-bit - but shifting the 16-bit data works) - 

If I change format on the fly - is it necessary to clock out what could have been there - for instance - going from 16-bits to 8 - I am noticing some
stale data being read by the 8-bit driver - it would appear to be left over from the previous transaction.

For instance - can I do this:

spiREG3->DAT1 = outb2 | 0x06FE0000;     // transmit register address // FMT2 USED - Format 2 is 16 bits 

and that is followed (by the appropriate set up here)

spiREG3->DAT1 = 0x00 | 0x05FE0000; // clock out data - Format 1 is used which is 8 bits

I thought that would work - but maybe more needs to be done when changing format on the same SPI bus.

Thanks,
John W.

  • Hello All,

    Well, I made sure even though one of the devices is write only; I made sure and read back all of the bytes and this seems to be OK now - I thought I had balanced that out - looks like I had missed one 16-bit read - and this is working.

    So, asked and answered I suppose.

    All kidding aside - I prefer SPI over I2C.

    Regards,
    John W.
  • Hi John,

    Looks like your problem is resolved with your own investigation.

    Are you in SPI mode or in MibSPI mode?

    If you are in SPI mode are you somehow changing the DFSEL of the SPIDAT1) on the fly while the data is being shifted out?

    Unlike the data where it is double buffered (data buffer and shift register), the data format register is not. While the data is being shifted, I would image if the data format is changed the kernel statemachine can get confused.

    i also think the MibSPI mode will help you in this regard as you can specify different formats for different chip selects before your start the transfer. You don't need to change the formats on the fly.
  • Hello Charles,

    Thanks for your answer.

    Another issue that exists on this SPI bus is we have an older RTC that requires compatibility mode to work properly.

    I have tried about everything to get that to work - and I can only get that working in the traditional SPI mode using compatibility mode.
    I have to disable compatibility mode for the other two SPI peripherals on that bus. But it works; I just need to be careful about the clocking.

    So, if there is a way to get all of that to work with MibSPI and SPI - I can give it a try but right now we are running in SPI mode only due to the compatibility issue.

    Thanks,
    John W.