I have try to interface W25Qxx with MSP430F5529 but it fails to read buffer Please find the issue & let me know asap.
int main(void)
{
volatile unsigned int i;
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
P1OUT |= 0x02; // Set P1.0 for LED
// Set P1.1 for slave reset
P1DIR |= 0x03; // Set P1.0-2 to output direction
P3SEL |= BIT3+BIT4; // P3.3,4 option select
P2SEL |= BIT7; // P2.7 option select
UCA0CTL1 |= UCSWRST; // **Put state machine in reset**
UCA0CTL0 |= UCMST+UCSYNC+UCCKPL+UCMSB; // 3-pin, 8-bit SPI master
// Clock polarity high, MSB
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
P1OUT &= ~0x02; // Now with SPI signals initialized,
P1OUT |= 0x02; // reset slave
// for(i=50;i>0;i--); // Wait for slave to initialize
// MST_Data = 0x01; // Initialize data values
// SLV_Data = 0x00; //
// while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
// UCA0TXBUF = MST_Data; // Transmit first character
while(1)
{
Read_SingleBytes(0x3);
}
__bis_SR_register(LPM0_bits + GIE); // CPU off, enable interrupts
}
int datacount=0;
unsigned char data=0;
unsigned char GCu_Tx_Data[10]={0};
unsigned char GCu_Recieved_Data[10]={0};
unsigned char sFLASH_SendByte(unsigned char *uData,unsigned char count)
{
// Clear Rx interrupt flag
while(!(UCA0IFG&UCTXIFG));
UCA0IFG&=~UCRXIFG;
for(datacount=0;datacount<count;datacount++)
UCA0TXBUF = uData[datacount];
// Wait for transfer to complete
while (UCRXIFG==0);
// Receive data
*uData = UCA0RXBUF;
return *uData;
}
unsigned char Read_SingleBytes(unsigned int LIu_Flash_Add)
{
unsigned char LCu_Read_Data=0;
spi_chipLow();
GCu_Tx_Data[0] = 0x02; //read
GCu_Tx_Data[1] = ((LIu_Flash_Add & 0xFF000000) >> 24);
GCu_Tx_Data[2] = ((LIu_Flash_Add & 0xFF0000) >> 16);
GCu_Tx_Data[3] = ((LIu_Flash_Add & 0xFF00) >> 8);
GCu_Tx_Data[4] = (LIu_Flash_Add & 0xFF);
LCu_Read_Data=sFLASH_SendByte(GCu_Tx_Data,5);
spi_chipHigh();
return(LCu_Read_Data);
}
void spi_chipHigh(void)
{
SLAVE_CS_OUT |= SLAVE_CS_PIN;
}
void spi_chipLow(void)
{
SLAVE_CS_OUT &= ~(SLAVE_CS_PIN);
}