9bit SPI Interface (3-wire), teensy 3.2

Status
Not open for further replies.

epikao

Active member
Hello,

TFT/Display Controller sometimes use a 3-Wire 9bit SPI Interface (9 bit = command/data).
Does somebody know if this 9bit is available on the teensy 3.2?

I have checked the SPI.h... there I see only the possibilty to transfer 1x, 2x, 3x etc. bytes, but not exactly 9bit.

thank you
 
Last edited:
Yes it is possible. There is a way to set the frame size from 4-16 bits.

It is in SPI section of the reference manual.

You do this by setting one of the CTAR registers and then specify that CTAR as part of an SPI operation...
By default we have the two CTAR registers set to 8 and 16 bit mode. But I see instances in the code that set the 2nd ctar to 9 bit mode.

Right now I am not sure of a clean way to do this. You could probably start a transaction, than update the FMSZ value of CTAR1 for the appropriate SPI module and then do a SPI.transfer16(value) and have it transfer only 9 bits
 
phuu, that looks not easy,
I just had a quick look on the reference manual:
https://www.pjrc.com/teensy/K20P64M72SF1RM.pdf
SPI_CTAR Teensy.png

I assume I most change something in the SPI.h file - and FMSZ?

inTransactionFlag = 1;
#endif
if (SPI0_CTAR0 != settings.ctar) {
SPI0_MCR = SPI_MCR_MDIS | SPI_MCR_HALT | SPI_MCR_PCSIS(0x1F);
SPI0_CTAR0 = settings.ctar;
SPI0_CTAR1 = settings.ctar| SPI_CTAR_FMSZ(8); // change to SPI0_CTAR1 = settings.ctar| SPI_CTAR_FMSZ(9); - but how...?
SPI0_MCR = SPI_MCR_MSTR | SPI_MCR_PCSIS(0x1F);
}
}

and usually I should write 9bit and then write/read 8bit...
 
phuu, that looks not easy,
I just had a quick look on the reference manual:
https://www.pjrc.com/teensy/K20P64M72SF1RM.pdf
View attachment 10411

I assume I most change something in the SPI.h file - and FMSZ?

inTransactionFlag = 1;
#endif
if (SPI0_CTAR0 != settings.ctar) {
SPI0_MCR = SPI_MCR_MDIS | SPI_MCR_HALT | SPI_MCR_PCSIS(0x1F);
SPI0_CTAR0 = settings.ctar;
SPI0_CTAR1 = settings.ctar| SPI_CTAR_FMSZ(8); // change to SPI0_CTAR1 = settings.ctar| SPI_CTAR_FMSZ(9); - but how...?
SPI0_MCR = SPI_MCR_MSTR | SPI_MCR_PCSIS(0x1F);
}
}

and usually I should write 9bit and then write/read 8bit...

Did you ever get this working? I have some 9-bit(3-wire) tft displays I would like to use too.
 
Status
Not open for further replies.
Back
Top