Tool/software:
Hi,
I am using MSP430FR2355 controller for my project, i want to use SPI communication on this. I tried lot but i am unable to get success. My controller need to be act as Master only data transfer(no need to receive data).
I want to use port pins: 12,13,14 for SPI communication(UCB1)
Here is my code,
void spi_init()
{
P4SEL0 |= BIT5| BIT6 | BIT7;
//Clock Polarity: The inactive state is high
//MSB First, 8-bit, Master, 3-pin mode, Synchronous
UCB1CTLW0 = UCSWRST; // **Put state machine in reset**
UCB1CTLW0 |= UCCKPL | UCMSB | UCSYNC
| UCMST | UCSSEL__SMCLK; // 3-pin, 8-bit SPI Slave
UCB1BRW = 0x20;
//UCB1MCTLW = 0;
UCB1CTLW0 &= ~UCSWRST; // **Initialize USCI state machine**
UCB1IE |= UCRXIE; // Enable USCI0 RX interrupt
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCI_B1_VECTOR
__interrupt void USCI_B1_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCI_B1_VECTOR))) USCI_B1_ISR (void)
#else
#error Compiler not supported!
#endif
{
switch(__even_in_range(UCB1IV,USCI_SPI_UCTXIFG))
{
case USCI_NONE: break; // Vector 0 - no interrupt
case USCI_SPI_UCRXIFG:
UCB1IFG &= ~UCRXIFG;
break;
case USCI_SPI_UCTXIFG:
if(SPI_byte_ptr < SPI_no_of_bytes)
{
UCB1TXBUF = SPI_buffer[SPI_byte_ptr++]; // Transmit characters
UCB1IE |= UCTXIE;
}
else
{
UCB1IE &= ~UCTXIE;
UCB1IFG &= ~UCTXIFG;
}
break;
default: break;
}
}
While first time execute the code the interrupt will works after that, interrupt will not work.
while watching on the oscilloscope, there is no data transmission was happening, but CLK pin high state continuously.
Help to come out for this.
BR,
Yuvaraj V