Other Parts Discussed in Thread: MSP430G2553
Hai,
Iam trying to interface msp430G2553 with serial eeprom 25LC1024. But when reading 0xFF is on RXBUF .
Iam sure it is not working then how can I understand the code is written successfully or not
My programming IDE is CCS v5
The write and read code is posted below separately....
//write procedure
//////////////////////////////////////
#include <msp430g2553.h>
volatile char received_ch = 0;
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1OUT |= BIT5; //slave select pin
P1DIR |= BIT5;
P1SEL = BIT1 | BIT2 | BIT4;
P1SEL2 = BIT1 | BIT2 | BIT4;
UCA0CTL1 = UCSWRST;
UCA0CTL0 |= UCCKPH + UCMSB + UCMST + UCSYNC; // 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**
P1OUT &= (~BIT5); // Select Device slave select pin
while (!(IFG2 & UCA0TXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = 0x06; // Set the write enable latch (enable write operations)
P1OUT |= (BIT5);
P1OUT &= (~BIT5);
while (!(IFG2 & UCA0TXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = 0x02; // Write data to memory array beginning at selected address
// P1OUT |= (BIT5);
// P1OUT &= (~BIT5);
while (!(IFG2 & UCA0TXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = 0x00;
while (!(IFG2 & UCA0TXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = 0x00;
while (!(IFG2 & UCA0TXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = 0x01;
//device address sent as three 8 bit data 00000000 00000000 00000001
while (!(IFG2 & UCA0TXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = 0xAB; //data
P1OUT |= (BIT5);
// P1OUT &= (~BIT5);
// while (!(IFG2 & UCA0RXIFG)); // USCI_A0 RX Received?
// received_ch = UCA0RXBUF; // Store received data
P1OUT |= (BIT5); // Unselect Device
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
Read procedure
/////////////////
#include <msp430g2553.h>
volatile char received_ch = 0;
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1OUT |= BIT5;
P1DIR |= BIT5;
P1SEL = BIT1 | BIT2 | BIT4;
P1SEL2 = BIT1 | BIT2 | BIT4;
UCA0CTL1 = UCSWRST;
UCA0CTL0 |= UCCKPH + UCMSB + UCMST + UCSYNC; // 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**
P1OUT &= (~BIT5); // Select Device
while (!(IFG2 & UCA0TXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = 0x03; //Read data from memory array beginning at selected address
while (!(IFG2 & UCA0TXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = 0x00;
while (!(IFG2 & UCA0TXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = 0x00;
while (!(IFG2 & UCA0TXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = 0x01;
// P1OUT |= (BIT5);
// P1OUT &= (~BIT5);
while (!(IFG2 & UCA0RXIFG)); // USCI_A0 RX Received?
received_ch = UCA0RXBUF; // Store received data
P1OUT |= (BIT5); // Unselect Device
}
//////////////////////////////////////////////////////////
SPI eeprom link is given below
http://ww1.microchip.com/downloads/en/DeviceDoc/22064D.pdf
Please spot the error....