Hi Everyone,
I am new to the msp430 and I am trying to receive data back from a serial eeprom (m95128). I am not seeing any data on the UCA0RXBUF after i send data. also there is no clock signal generated when i should be receiving data. The clock is generated when I send the data. What am I am doing wrong?
#include "msp430f5438.h"
void main (void){
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P6DIR |= 0X10; // Enable P6.4 as output (eeprom) chip select
P6OUT |= 0X10; // Set High - Disable eeprom
init_spi_a0();
select_spi_device(EEPROM_DEVICE); // enables chip select on eeprom
USCI_A0_SPI(M95128_RDSR); // WRITE TO STATUS REGISTER
EEPROM_CS_DISABLE();
}
void init_spi_a0(void){
P6OUT |= 0x10;
P6DIR |= 0x10; // Slave Reset
P3SEL |= 0x31; // P3.5,4,0 option select
UCA0CTL1 |= UCSWRST; // **Put state machine in reset**
UCA0CTL0 |= UCMST+UCSYNC+UCCKPL+UCMSB; // 3-pin, 8-bit SPI master
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 0x02; // /2
UCA0BR1 = 0;
UCA0MCTL = 0; // No modulation
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt
__bis_SR_register(GIE); // enable interrupts
}
unsigned char USCI_A0_SPI(unsigned char u1_txdata)
{
unsigned char u1_rxdata;
while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = u1_txdata; // Send data
__delay_cycles(40); // Add time between transmissions to
// make sure slave can process information
while(UCRXIFG==0); // USCI_A0 RX buffer ready?
u1_rxdata = UCA0RXBUF; //
return(u1_rxdata);
}
Does anyone know why i am not receiving data on UCA0RXBUF?
Thanks for any help.