SPIM Send 7 Bits Data | Cypress Semiconductor
SPIM Send 7 Bits Data
I am using CY8C24894 to develop a serial port comminication with IC. The communication require PSoC to send a 7 bit data only to IC. I implement it using SPIM UM, but i got a problem with the SPIM to send a 7 bits data to my IC.
My method is to use SPIM to send 1 byte data, and AND the SPIM sclk 8 pulse signals with a counter which has a duty cyle of 7/8, in the way 1 pulse will be masked and only the rest 7 sclk pulse can be sent out.
my problem is how can I make sure the counter can mask exactly the 1st pulse of sclk or the last pulse of sclk, in order to pass the desired 7 data bits? I have attached the diagram to illustrate the desired situations.
I have try the following method to solve it, but none of them works so far:
1) programming in main.c to start counter and send data by SPIM.
"while( ! (SPIM_bReadStatus() & SPIM_SPIM_TX_BUFFER_EMPTY ) );
The starting time of counter is not constant, thus position of the masked sclk pulse is random every time.
2) use SPIM ISR to start counter. the SPIM interrupt mode is TXRegEmpty. the counter starting time is constant now, but it will delay a few cycle of sclk. Thus the first 4 sclk pulses will all be masked as showed in attached file.
Right now i am stucked here, could anyone give me some suggestion on sending only 7 bits data by SPIM?