Dear all,
I’m using the UCA2 on an MSP430FR5994 to do some SPI stuff. Having different devices connected i handle the chip select manually.
The initialization is done by this code snippet
SPI_CTLW0 = UCSWRST; SPI_CTLW0 |= UCSSEL__SMCLK | UCCKPH_1 | UCCKPL__LOW | UC7BIT__8BIT | UCMSB | UCMST__MASTER | UCSYNC | UCMODE_0; SPI_BRW = 0; SPI_CTLW0 &= ~UCSWRST;
afterwards i e.g. send a byte by
SPI_TXBUF = byte_to_write; unsigned int counter = SPI_TIME_OUT_COUNTER; while ( (!(SPI_IFG & UCTXIFG)) && (counter > 0) ) --counter;
With this implementation i have two problems, I hope you can help me with or point in the right direction:
- After sending the byte the level of the tx pin is (often) high and gets only low when e.g. reading and therefore setting the tx-buffer to 0x00. Is there a good fix without the need to send 0x00 afterwards? Did i misconfigure something?
- It takes a surprisingly long time (MCLCK = SPI-CLOCK = 4MHz) of approx. 3-4us until the next byte can be send. Is there a better/faster way?
Thanks for your help and best wishes
Tobias