Content originally posted in LPCWare by Pacman on Sun Sep 22 12:38:19 MST 2013
I find this a very good and important question and I agree with you, though I haven't looked at any code.
First of all... Are we talking about [color=#00f]L[/color]east/[color=#00f]M[/color]ost [color=#00f]S[/color]ignificant [color=#00f]B[/color]yte, or [color=#00f]l[/color]east/[color=#00f]m[/color]ost significant [color=#00f]b[/color]it ?
If looking in the UM10503, on page 357 I read:
Quote:
The bit order is optimized for MSB first. Interfaces that require LSB first should use a software instruction (RBIT) to reverse the bit order (not supported by the ARM Cortex-M0).
The above looks very good to me and very clear (unless MSB/LSB means byte order, but that would be a complete disaster), BUT as you say, if I look at page 366 (Section 18.6.4),REG[0...15], I see the following:
Quote:
At an active shift clock data is right shifted; captured data is shifted in at bit 31, and register data is shifted out from bit 0.
Table 220:
Quote:
Symbol REG: At each active shift clock the register shifts right; loading REG(31) with data captured from DIN(n) and DOUT(n) is set to REG(0).
That is a bit confusing.
I think that if it's not possible to output the msb (most significant bit) first, SGPIO would be more or less useless, because:
[list]
[*]I2C sends msb first.
[*]I2S (and S/PDIF) sends msb first (I2S is also big endian).
[*]SPI sends msb first.
[*]UART sends msb first.
[*]SD/MMC (which is basically SPI) card sends msb first.
[/list]
(any other serial interfaces we need to emulate ?)
In other words: There would be very, very little benefit in shifting out the least significant bit first.
If NXP tested emulating one of the above mentioned interfaces (I do expect that they did), then it should be possible to shift out msb first.
It would be ideal to have an option to control the shift-direction (a single bit in a control-register), but I have not found anything.
If, on the other hand, you have trouble with big/little endian, you should be able to set up the DMA to do the byte-reversing.
In the UM10503, there's an example (no code, though) on how the SGPIO can be used for extending the I2S from 2 channels to 8 channels.
If that is tested and it works using the DMA, then the most significant bit simply must go first.
I still haven't been able to send code to my 43xx, so unfortunately I cannot verify anything.