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.

CC2530 SPI Problem

Other Parts Discussed in Thread: CC2530

Hi,

I'm using an CC2530 USART0 in three wire SPI master mode. I have three different devices connected to the SPI (real time, clock memory and accelerometer) but each uses slightly different control (clock polarity and phase) so I have to change the control register (U0GCR) on the the fly to talk to each device. As I understand it, in three wire mode the SSN pin isn't used so I'm configured it as an output and am using it for a chip select for my real time clock.

It basically works but I have a problem. When I disable the SPI receiver (U0CSR_RE) and reconfigure the control register (U0GCR), P0_4 (the SSN pin) changes state and causes a false write to my RTC

I'm sure I'm doing something wrong but can't find out what it is? Any help on this would be very much appreciated.

// Set up code --------------------------------------------------------------------------

 // Configure USART0 for Alternative 1 => Port P0 (PERCFG.U0CFG = 0)

 // To avoid potential I/O conflict with USART1:
 // configure USART1 for Alternative 2 => Port P1 (PERCFG.U1CFG = 1)
    PERCFG = (PERCFG & ~PERCFG_U0CFG) | PERCFG_U1CFG;

 // Give priority to USART 0 over USART 1 for port 0 pins
    P2DIR = (P2DIR & ~P2DIR_PRIP0) | P2DIR_PRIP0_0;

 // Set pins 2, 3 and 5 as peripheral I/O and pins 0, 1, 4, 6 & 7 as GPIO output
    P0SEL = (P0SEL & ~BIT0 & ~BIT1 & ~BIT4 & ~BIT6 & ~BIT7 ) | BIT5 | BIT3 | BIT2;

    P0DIR = P0DIR | BIT7 | BIT1 | BIT4 ;
       
    P0INP = 0xff;                   // port 0 tristate
    P2INP = 0x0f;                   // port 2 tristate
   
    // Set port0_2 to input
    P0DIR = (P0DIR & ~BIT2);

// End of set up -------------------------------------------------------------------------

 

// code that causes P0_4 to change --------------------------------------------

// disable the SPI receiver

   U0CSR = U0CSR & ~(U0CSR_RE);

 // change the configuration
  
   U0GCR = (U0GCR & ~(U0GCR_BAUD_E | U0GCR_CPOL | U0GCR_CPHA  ))
         | SPI_BAUD_E | U0GCR_ORDER;
 
  // enable the receiver
 
    U0CSR |= U0CSR_RE;

// end of problem code ---------------------------------------------------------------