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.

  • Resolved

How I generate CLOCK in SPI AT45DB3210D

Prodigy 70 points

Replies: 5

Views: 1661

hello,

 My job to communicate between MSP430F1481 & AT45DB3210D.

spi_init()

  {

P5DIR |=0x0C;                            // P5.1,2,3 SPI option select
   P4DIR |=0x08;
   P4OUT |=0x00;
   
   UCTL1 |= CHAR;                            // 8-bit character
   UCTL1 |= SYNC;   
   UTCTL1 |= SSEL0;               // UCLK = ACLK
   UBR01 = 0x03;                  // 8MHz 9600
   UBR11 = 0x00;                  // 8MHz 9600
   UMCTL1 = 0x00;                            
   UCTL1 &= ~SWRST;

/////////////////////or//////////////////

  UCTL1 |= CHAR;                            // 8-bit character
   UCTL1 |= SYNC;   
   UTCTL1 |= SSEL1;               // UCLK = EXT CLK 8MHz. crystal
   UBR01 = 0x41;                     // 8MHz 9600
   UBR11 = 0x03;                     // 8MHz 9600
   UMCTL1 = 0x00;                            
   UCTL1 &= ~SWRST;

}

i put this code for SPI communication...

but unfortunatelt i donot match any cloack generation. 1. ACLK, 2. External master clock.

in clk pin, i get always high status.

regards

rishi

 

 

  • focus.ti.com/lit/ml/slap117/slap117.pdf

    check out the above document

  • In reply to Kshatriya:

    Dear Kshatriya,

    i m beginner in MSP430Fxxx controller.

    i saw your link, but it is not help me.

     

    please look at this code,  this is not generating any clock on PIN 5.3.

     

    #include <msp430x14x.h>
    #include <string.h>

    #define SCK_HIGH      P5OUT |=0x08       //clock   out
    #define SCK_LOW       P5OUT &=~0x08
    #define SIN_HIGH      P5OUT |=0x04       //data  out
    #define SIN_LOW       P5OUT &=~0x04
    #define sout          (P5IN & 0x02)/(0x02)   // data in
    #define CS_HIGH       P4OUT |=0x08        // chip select high
    #define CS_LOW        P4OUT &=~0x08        // chip select low

    void cs_delay(void);
    void spi_init();
    void testspi(void);

    void main()
    {
     WDTCTL = WDTPW + WDTHOLD;
     spi_init();

     while(1)
      {
           testspi();
      }  
    }



    void spi_init()
    {
       P5DIR |=0x0C;                            // P5.1,2,3 SPI option select
       P4DIR |=0x08;
       P4OUT |=0x00;
      
       UCTL1 |= CHAR;                            // 8-bit character
       UCTL1 |= SYNC;  
       UTCTL1 |= SSEL1;               // UCLK = mode 10
     
       UBR01 = 0x41;                  // 8MHz 115200
       UBR11 = 0x03;                  // 8MHz 115200
       UMCTL1 = 0x00;                           
       UCTL1 &= ~SWRST;   
    }  

    void cs_delay(void)
    {
      int Delay;
      for(Delay=0;Delay<18;Delay++)
      {
          _NOP();
          _NOP();
          _NOP();
      }
    }

    void testspi(void)
    {
      unsigned char r='U';
      while(1)
      {
       TXBUF1 = r;
        while((IFG2 & UTXIFG1)==0);
         cs_delay();
       }
    }

     

    Regards,

    rishi

     

  • In reply to Rishi Singhal:

    I think ur controller is Master in spi communication so add the below code

    U1CTL = CHAR + SYNC + MM + SWRST;         // 8-bit, SPI, Master

    enable ur spi module by

          ME2 |= USPIE1;                            // Module enable
          U1CTL &= ~SWRST;                          // SPI enable

    any way once read SPI communication chapter in ur users guide

  • In reply to Kshatriya:

    Thanks Kshatriya,

    i get the clock.

     

    but it is creating another doubt.

    i m using below code for spi initialiation.

     

    UCTL1 = CHAR + SYNC + MM + SWRST;         // 8-bit, SPI, Master
      UTCTL1 = CKPL + SSEL1 + STC;                   // Polarity, SMCLK, 3-wire
      UBR01 = 0x02;                                                  // SPICLK = SMCLK/2
      UBR11 = 0x00;
      UMCTL1 = 0x00;
      ME2 |= USPIE1;                                                 // Module enable
      UCTL1 &= ~SWRST;                                             // SPI enable
      IE2 |= URXIE1 + UTXIE1;                   // RX and TX interrupt enable

     

    in that i get the maximum 288.525 KHz. frquency.

    i want minimum 1 Mhz.

    How can i achieve this...

     

    Reagrds

    Rishi

  • In reply to Rishi Singhal:

    configure ur clock to external crystal using the below example in ur sample code

     fet140_uart11_19200_2.c      make proper modifications according to ur crystal frequency

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.