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.

MSP430x2xx SPI USI vs. USCI

Other Parts Discussed in Thread: MSP430G2553, CC115L, MSP430G2221

Hi,

I am trying to modify a C code based on MSP430G2221 to a new system based on MSP430G2553. The main difference is the SPI interface since MSP430G2221 is using the USI and MSP430G2553 which we are now applying has USCI. Further, we are using the TI radio chip CC115L in both systems.

I have modified the code for USI


 USISRL = inbyte;                                  // Load byte to send in USI shift register
 USICNT |= 8;                                         // Start to send 8 bits. USIIFG cleared 
 while(!(USICTL1 & USIIFG));             // Wait for all SPI bits to be sent

 return USISRL; // Copy rx SPI byte from Chipcon

 To the USCI:

  uint8_t temp;

  // Send 'inbyte'
  UCB0TXBUF = inbyte;
  while((IFG2 & UCB0RXIFG) == 0);
  temp = UCB0RXBUF; // Read RX and throw away to prevent overrun error.

  // Receive byte
  while (UCB0STAT & UCBUSY);
  UCB0TXBUF = 0; // Write data is a don't care.
  while((IFG2 & UCB0RXIFG) == 0);

  return UCB0RXBUF;

The compiler shows no error, but if I run my program, its always hanging in the lines where I use while((IFG2 & UCB0RXIFG) == 0);

I have then commented these commands out. But then its hanging somewhere else where it hasn't complained before.

Thanks!

 

  • What about the USCI initialization? Maybe it is simply not running. No clock source (or 0Hz clock), not release dfrom UCSWRST, 4-wire mode selected that switched the USCI to slave mode? Port config wrong?

    Th epart you postead looks good.Except that it doesn' tmatch the USI code in funcitonality.

    The USi code was sending 8 bit and returning the 8 bits received in the meantime. The USCI code is sending 8 bit (command/request), then sending another 8 bit in order to receive an answer byte to the previously sent command. Which appears correct, but is not the same as the USI code, which had to be called twice (first result to be discarded) for the same functionality.

  • Hi Jens,

    thanks for your reply! I have already tested the USCI and BCS initialization in another code with MSP430G2553  already and it works.

    I suppose that the problem is as you said in the spi functionality. How what would be the correct modification? 

    I have now changed the code to:

    UCB0TXBUF = inbyte;
    while((IFG2 & UCB0RXIFG) == 0);
    temp = UCB0RXBUF;

    return temp;

    But the code still always hangs in the lines where I use while((IFG2 & UCB0RXIFG) == 0); to wait for last SPI byte to be sent. Why can't I just replace while(!(USICTL1 & USIIFG)); with while((IFG2 & UCB0RXIFG) == 0); to adapt the USI mode to the USCI mode?

     

    Thanks a lot!

     

     

     

     

  • Hi Yue,

    We are facing a similar problem with UCI and CC115L and are unable to finish boot on reset, did you ever get it to work?

    Thanks

    Yaniv