This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SPI communication not responded on MSP430F47167 with DATAFLASH(45DB321)

Other Parts Discussed in Thread: MSP430F2012

Dear All,

I am trying to run SPI on my hardware from last since few days.All initilization and hardware are proper.

I will set 1 MHz CLK

and try to read Device id from dataflash, i was saw a waveform on SI line and CLK also seen on DSO,but i cant seen any SO output

Please help.It showing continuously low state(SO).

 

 

  • Hi mayur,

    TI has an application note which uses an SPI Flash connected to an MSP430F2012. You can find it here http://focus.ti.com/mcu/docs/litabsmultiplefilelist.tsp?sectionId=96&tabId=1502&literatureNumber=slaa405a&docCategoryId=1&familyId=342.

    Maybe you can put it into good use.

    Rgds
    aBUGSworstnightmare

  • 2388.spi_1.txt
    /*--------------------------------------------------------------------
     * Name   :main.c
     * Purpose: Writing and Reading data to DATAFLASH using SPI
     * Date   :2 Oct 2010
     * -----------------------------------------------------------------*/
    
    #include  <msp430x471x7.h>
    
    /*-------------------------------------------------------------------
     * 	MACRO definitions
     * -----------------------------------------------------------------*/
    #define CS_DHIGH  P2DIR|=BIT0
    #define CS_DLOW   P2DIR&=~BIT0
    
    /*------------------------------------------------------------------
     * 	Function Prototyping
     * ----------------------------------------------------------------*/
    void delay(unsigned int itime);
    void init_spi(void);
    void init_UART(void);
    void init_cpu(void);
    
    /*--------------------------------------------------------------------
     * Function name:main
     * Purpose: Initialization for all modules and call function buffr1wr
     * 			and buffr1rd continuosly. 
     * -----------------------------------------------------------------*/
    
    void main(void)
    {	
    	init_cpu();
    	init_spi();
    	init_UART();
    	
    	
    	while(1)
    	{	
    		
    		CS_DHIGH; 
    		CS_DLOW;
    		delay(1);
    		UCB1TXBUF=0x9F;
    		delay(1);
    		while(!(UC1IFG&UCB1RXIFG));
    		UCA1TXBUF=UCB1RXBUF;
    				
    		UCB1TXBUF=0xFF;
    		while(!(UC1IFG&UCB1RXIFG));
    		UCA1TXBUF=UCB1RXBUF;
    				
    		UCB1TXBUF=0xFF;
    		while(!(UC1IFG&UCB1RXIFG));
    		UCA1TXBUF=UCB1RXBUF;
    				
    		UCB1TXBUF=0xFF;
    		while(!(UC1IFG&UCB1RXIFG));
    		UCA1TXBUF=UCB1RXBUF;
    							
    		delay(1);
    		CS_DHIGH;
    		delay(10);				        							
    	}
    }
    
    void init_cpu(void)
    {
       volatile unsigned int i;
    
      WDTCTL = WDTPW +WDTHOLD;                  // Stop WDT
      FLL_CTL0 |= XCAP14PF;                     // Configure load caps
    
      // Wait for xtal to stabilize
      do
      {
        IFG1 &= ~OFIFG;                         // Clear OSCFault flag
        for (i = 0x47FF; i > 0; i--);           // Time for flag to set
      }
      while ((IFG1 & OFIFG));                   // OSCFault flag still set?
    
    }
    /*--------------------------------------------------------------------
     * Function name:delay
     * Purpose: General delay function. 
     * -----------------------------------------------------------------*/
    
    void delay(unsigned int itime)
    {
      unsigned int i,j;
      for(i=0;i<itime;i++)
        for(j=0;j<50;j++);
        
    }
    /*--------------------------------------------------------------------
     * Function name:init_UART
     * Purpose: Initialization UART for serial communication
     * 			at baudrate of 9600. 
     * -----------------------------------------------------------------*/
    
    void init_UART(void)
    {
      UCA1CTL1 |=UCSWRST;
      UCA1CTL0 = UCMODE_0 ;
      UCA1CTL1 = UCSWRST + UCSSEL_1;
      UCA1BR0 = 0x03;
      UCA1BR1 = 0x00;
      UCA1MCTL = 0x06;
      P1SEL |=BIT6 + BIT7;
      
      UCA1CTL1&=~UCSWRST;  
    }
    void init_spi(void)
    {
    	UCB1CTL1|=UCSWRST;
      	UCB1CTL0 =UCSYNC + UCMODE_0+ UCMST + UCMSB;
      	UCB1CTL1 =UCSSEL_2 + UCSWRST;
      	UCB1BR0 = 0x00;      //1MHz CLOCK.
      	UCB1BR1 = 0x00;
       	P2SEL|= BIT1+ BIT2+BIT3;
      	P2DIR = BIT1+ BIT3;
       	UCB1CTL1&=~UCSWRST; 
      	
    }	
    
    
    Thanks for sending file,but im beginer for embedded system and im unable to understand the code basics.I am sending you my code as an attachment please tell me where can i make a mistake?

     

     

    Thanks in advance

     

     

    Mayur S.

  • From your information, I can only guess what's happening.

    THe likely cause is that you're not chip-selecting the device first. YOu need to connect a GPIO pin with the CS pin of the slave. Before you start the data transfer, you need to pull down the CS pin, then start the transfer. As long as CD is not pulled low, the slave will have its output pin in high-impedance state, so nobodfy is driving this line, resulting in a LOW signal if measured with an osczilloscope or multimeter (while a logic tester would show 'high impedance' state).

    You cannot simply tie the CS line to low, as the high/low transition is required to synchronize the bit ordering (there are no start/stop bits on SPI) and the low/high transition is used to end a transfer block or cancel an ongoing transfer and set the state logic back to start.

    The maximum SPI frequency is 13MHz for your ram device.

**Attention** This is a public forum