Tool/software: Code Composer Studio
Hello,
I want to setup a SPI-communication from a MSP430F5529 to a Display. I am using a libary to control the display, but I have to setup a SPI-protocol for faster transmittion.
The libary has four function (for the transfer), which are called up in this order:
U8X8_MSG_BYTE_INIT
U8X8_MSG_BYTE_START_TRANSFER
- Any mix of
U8X8_MSG_BYTE_SEND
andU8X8_MSG_BYTE_SET_DC
U8X8_MSG_BYTE_END_TRANSFER
U8X8_MSG_BYTE_INIT is for the initialisation of the SPI. The U8X8_MSG_BYTE_SEND
function is for the transmition of the data. I need to send arg_int
bytes, because arg_ptr
will point to a buffer of size arg_int
. The Chip-Select/Slave-Select is handeld in U8X8_MSG_BYTE_START_TRANSFER and U8X8_MSG_BYTE_END_TRANSFER, so I don't have to deal with it.
The two statements I hve to replace in the tmeplate:
case U8X8_MSG_BYTE_INIT: P3SEL |= BIT0+BIT1+BIT2; // P3.0,1,2 option select MOSI MISO CLK UCB0CTL1 |= UCSWRST; // **Put state machine in reset** UCB0CTL0 |= UCMST+UCSYNC+UCMSB;//UCMODE_2; // 3-pin, 8-bit SPI master // MSB, clock polarity high UCB0CTL1 |= UCSSEL_2; // SMCLK Clock Auswahl UCB0BR0 = 0x04; // Baudrate 13Mhz/4 UCB0BR1 = 0; // The clock frequency is scaled by UCB0BR0 + UCB0BR1 * 256 UCB0CTL0 &= ~UCCKPL; // Clock polarity UCB0CTL0 &= ~UCCKPH; // Clock phase UCB0CTL1 &= ~UCSWRST; UCB0IE |= UCRXIE+UCTXIE; // Enable USCI_B0 RX+TX interrupt break;
and:
uint8_t *data;
case U8X8_MSG_BYTE_SEND: data = (uint8_t *)arg_ptr; while (!(UCB0IFG&UCTXIFG)); // USCI_B0 TX buffer ready? while( arg_int > 0 ) { while (!(UCB0IFG&UCTXIFG)); // USCI_B0 TX buffer ready? __delay_cycles(20); P2DIR |= BIT3; P2OUT |= BIT3; UCB0TXBUF = *data; arg_int--; data++; } break;
I am stuck in the troubleshooting a few days now. I already checked many examples and the datasheet but I can't find the fault/faults,
I would really appreciate some help. Thanks