Other Parts Discussed in Thread: MSP430WARE
Hi everyone,
Now i have MSP430F67791 interface the W25q64 winbond chip.But communication is not working.what happened?
This is my following code details,
interface pin details for your reference,
SCLK P3.3 SCK
SOMI P3.4 DO
SIMO P3.5 DI
CS P3.6 CS
void spi_init(void)
{
UCA1CTL1 = UCSWRST;
P3OUT &= ~BIT6; // Clear P1.0
P3DIR |= BIT6; // Set P1.0 to output direction
P3SEL0 = BIT3| BIT4 | BIT5 ; // Set P3.0,P3.1,P3.2 to non-IO
UCA1CTL0 |= UCCKPH + UCMSB + UCMST + UCSYNC;
UCA1CTL1 |= UCSSEL_2; // SMCLK
UCA1BR0 |= 0x02;
UCA1BR1 = 0x00;
UCA1MCTLW = 0;
UCA1CTL1 &= ~UCSWRST;
}
void spi_chipHigh(void)
{
P3OUT |= CS;
}
void spi_chipLow(void)
{
P3OUT &= ~CS;
}
int datacount=0;
unsigned char data=0;
unsigned char GCu_Tx_Data[10];
unsigned char GCu_Recieved_Data[10];
uint8_t sFLASH_SendByte(unsigned char *uData,unsigned char count)
{
while(!(UCA1IFG &= UCTXIFG));
for(datacount=0;datacount<count;datacount++)
UCA1TXBUF = uData[datacount];
while (!(UCA1IFG & UCRXIFG));
uData[0] = UCA1RXBUF;
return *uData;
}
unsigned char Read_SingleBytes(unsigned int LIu_Flash_Add){
unsigned char LCu_Read_Data=0;
spi_chipLow();
GCu_Tx_Data[0] = 0x03; //read
GCu_Tx_Data[1] = (LIu_Flash_Add >> 16) & 0xFF;
GCu_Tx_Data[2] = (LIu_Flash_Add >> 8) & 0xFF;
GCu_Tx_Data[3] = (LIu_Flash_Add >> 0) & 0xFF;
LCu_Read_Data=sFLASH_SendByte(&GCu_Tx_Data[0],4);
spi_chipHigh();
return(LCu_Read_Data);
}
while(1)
{
Read_SingleBytes(0x000000);
}
If any coding issue pls tell me the exact reason and how to work properly guide me as soon as possible.Pls check the SPI init function this init register deatils are correct or not.And also check the whole program details and guide me the issue as soon as possible.