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 transfer get stuck in mmc card interface

Other Parts Discussed in Thread: CC2530

Hello Dear friends 

I am interfacing with MMC card with CC2530 and used SPI  on PORT0 at atlernate -1 position  with USART1

when Debug code, I found that cursur keep waiting on SPI_WAIT_RXRDY0(); function in below SPI_Tranfer_Byte(0xFF);

my code for transferring data with mmc card is below :

unsigned char SPI_Transfer_Byte(unsigned char byte)
{
unsigned char received_byte=0x00;
//SPDR=byte;
SPI_TX0(byte);
//while(!(SPSR & (1<<SPIF)));
SPI_WAIT_RXRDY0();
received_byte=SPI_RX0();
return(received_byte);
}

Please help to resolve this issue urgently

thanks and regard

  • What is in your SPI_TX0 and SPI_WAIT_RXRDY0?
  • Hello gm friend

    I have configure SPI-Master mode to communicate with MMC card with following information as below, but using D S Osilloscope no signal is seen on clock line, or MOSI line except chip select line

    I have configured SPI- USART PORT -1 in master mode CC2530 with following pin 

    i)P0_2 as chip_select for mmc SPI_CHIP_SELCT

    ii)P0_3 as serial clock SPI_CLOCK

    iii)P0_4 as SPI_MOSI

    iv) P0_5 as SPI_MISO 

    // USART1 Alt. 1 in SPI mode.
    #define XNV_SPI_INIT() \ st( \ /* Mode select UART1 SPI Mode as master. */\ U1CSR = 0; \ \ /* Setup for 115200 baud. */\ U1GCR = 11; \ U1BAUD = 216; \ \ /* Set bit order to MSB */\ U1GCR |= BV(5); \ \ /* Set UART1 I/O to alternate 2 location on P1 pins. */\ PERCFG |= 0x0; /* U1CFG */\ \ /* Select peripheral function on I/O pins but SS is left as GPIO for separate control. */\ P0SEL |= 0x38; /* SELP1_[5:2] */\ P0DIR |= 0x04; \ \ /* Give UART1 priority over Timer3. */\ P2SEL &= ~0x20; /* PRI2P1 */\ \ /* When SPI config is complete, enable it. */\ U1CSR |= 0x40; \ )

    #define SPI_BEGIN0() st(P0_2 = 0;)
    #define SPI_TX0(x) st(U1CSR &= ~0x02; U1DBUF = (x);)
    #define SPI_RX0() U1DBUF
    #define SPI_WAIT_RXRDY0() st(while (!(U1CSR & 0x02));)
    #define SPI_END0() st(P0_2 = 1;)

  • So, it is copied from LCD driver and I see no problem on it. I suggest you use scope to check SPI signal.
  • using D S Osilloscope no signal is seen on clock line, or MOSI line except chip select line
  • i have placed 33ohm resistance between CC2530 Micro controller and MMC card on all four SPI-commination line
  • If you don't see clock on clock line, you have to check this first. I suggest you disconnect your MMC module to check it again.

  • I had removed MMC card, and then checked signal on MOSI, Serial Clock Line, CHIP select.
    only MOSI and CHIP select line have shown waveform and No waveform is observed on SCLK line yet
    Please help in this regards
    anubhav
  • Which pin of CC2530 do you use as SCLK?

  • I have configured SPI- USART PORT -1 in master mode CC2530 with following pin

    i)P0_2 as chip_select for mmc SPI_CHIP_SELCT

    ii)P0_3 as serial clock SPI_CLOCK

    iii)P0_4 as SPI_MOSI

    iv) P0_5 as SPI_MISO
  • Try to measure P1.5 for SCLK.
  • Although i check clock waveform on P1_5 but no waveform is observed ,

    Although  i am using Alternate-1 for USART-1 for  SPI as per mentioned in datasheet of CC253XX in

    and

    PORT pin as

    I have configured in master mode CC2530 with following pin

    i)P0_2 as chip_select for mmc SPI_CHIP_SELCT

    ii)P0_3 as serial clock SPI_CLOCK

    iii)P0_4 as SPI_MOSI

    iv) P0_5 as SPI_MISO

    I am also posting snap shot of port config details taken from CC253XX.pdf datasheet

  • Try to use the following red part of XNV_SPI_INIT to replace yours.

    #define XNV_SPI_INIT() \
    st( \
      /* Mode select UART1 SPI Mode as master. */\
      U1CSR = 0; \
      \
      /* Setup for 115200 baud. */\
      U1GCR = 11; \
      U1BAUD = 216; \
      \
      /* Set bit order to MSB */\
      U1GCR |= BV(5); \
      \
      /* Set UART1 I/O to alternate 1 location on P0 pins. */\
      PERCFG &= (~BV(1));        /* U1CFG */\
      \
      /* Select peripheral function on I/O pins but SS is left as GPIO for separate control. */\
      P0SEL |= (BV(3)|BV(4)|BV(5));  /* SELP1_[5:2] */\
      P0SEL &= (~(BV(3)|BV(4)|BV(5))); \
    \
    /* Give UART1 priority over Timer3. */\
    P2SEL &= ~0x20; /* PRI2P1 */\ \
    /* When SPI config is complete, enable it. */\
    U1CSR |= 0x40; \ )
  • I did configuration as per your suggestion, But observed that no MOSI waveform and no SERIAL_CLOCK waveform but earlier MOSI waveform was observed on Pin

  • Try to revise the red part to XNV_SPI_INIT.

    #define XNV_SPI_INIT() \

    st( \

     /* Mode select UART1 SPI Mode as master. */\

     U1CSR = 0; \

     \

     /* Setup for 115200 baud. */\

     U1GCR = 11; \

     U1BAUD = 216; \

     \

     /* Set bit order to MSB */\

     U1GCR |= BV(5); \

     \

     /* Set UART1 I/O to alternate 1 location on P0 pins. */\

     PERCFG &= (~BV(1));        /* U1CFG */\

     \

     /* Select peripheral function on I/O pins but SS is left as GPIO for separate control. */\

     P0SEL |= (BV(3)|BV(4)|BV(5));  /* SELP1_[5:2] */\

     P0SEL &= (~(BV(3)|BV(4)|BV(5))); \

    \

    P2DIR |= 0x40; /* 1st priority: USART 1 */\ \

    /* Give UART1 priority over Timer3. */\

     P2SEL &= ~0x20; /* PRI2P1=0 */\ \

     P2SEL |= 0x40; /* PRI3P1=1 */\ \

    /* When SPI config is complete, enable it. */\

    U1CSR |= 0x40; \ )

  • Just test the following USART1 PORT0 SPI init function and confirm to see SCLK on P0.3.

    #define USART1_SPI_INIT() \
    st( \
      /* Mode select UART1 SPI Mode as master. */\
      U1CSR = 0; \
      \
      /* Setup for 115200 baud. */\
      U1GCR = 11; \
      U1BAUD = 216; \
      \
      /* Set bit order to MSB */\
      U1GCR |= BV(5); \
      \
      /* Set UART1 I/O to location on P0 pins. */\
      PERCFG &= (~BV(1));  /* U1CFG */\
      \
      /* Select peripheral function on I/O pins but SS is left as GPIO for separate control. */\
      P0SEL |= (BV(3)|BV(4)|BV(5));  /* SELP1_[5:2] */\
      /* P1.1,2,3: reset, LCD CS, XNV CS. */\
      P2DIR |= 0x40; /* 1st priority: USART 1 */ \
      \
      /* Give UART1 priority over Timer3. */\
      P2SEL &= ~0x20;  /* PRI2P1 */\
      P2SEL |= 0x40; /* PRI3P1=1 */\
      \
      /* When SPI config is complete, enable it. */\
      U1CSR |= 0x40; \
      /* Release XNV reset. */\
      P1_1 = 1; \
    )

  • hello
    I have been able to do config part of SPI with USART1 ok, but now accessing MMC card with same SPI bus, as card is not responding
    so am here stuck Please help to access MMC card
  • I still suggest you using scope to check if the SPI command is sent out correctly.
  • it will be great help if you can provide MMC source code for interfacing with CC2530
    thanks
    Anubhav
  • I only have experience on SPI to communicate with other HW not MMC so I don't have source code to you.