Ti Chipcon CC1110/CC2510 SPI problem

Thread Starter

Hamilton

Joined Jun 20, 2008
10
I'm attempting to use the SPI port on the Ti CC1110 SOC. All looks well but no serial data. I'm using USART1 alt 1 (P0_234&5), Master, MSB first. P0_2 is the /CS and is configured as a GPIO per the spec. I have a logic analyzer on /CS,MOSI,MISO,SCLK,TP(test point) and a scope on the XTAL clock. Clocks, Ports and USART regs are set.

Running the code below: debug registers show flags URX1IF & UTX1IF set and cleared as if it is working. USART TX Byte looks good also. /CS responds correctly to code, MISO is inverted from /CS. BUT SPI SCLK, Reg U1DBUF and MOSI stay 0x00,

code snippet:

Rich (BB code):
char addr , value;
addr = 255;
value = 255
 
do { 
CODEC_SS_LOW; // /CS enable PIN P0_2
URX1IF = 0; // Clear flag from first dummy byte
U1DBUF = addr; // Send address
TP_ON; // Just a Logic analyzer "marker" using P0_0 
while (!UTX1IF); // Wait for TX to finish
TP_OFF; // Just a Logic analyzer "marker" using P0_0
UTX1IF = 0; // Clear TX flag
URX1IF = 0; // Clear RX flag
U1DBUF = value; // Send value
TP_ON; // Just a Logic analyzer "marker" using P0_0
while (!UTX1IF); // Wait for end of data TX
TP_OFF; // Just a LogicPort "marker" using P0_0
UTX1IF = 0; // Clear flag 
CODEC_SS_HI; // /CS disable 
} while (0);
Q: 1.) I am ignoring U1UCR except FLUSH since UCR appears specfic to true USART apps. Is this my mistake?
2.) Slave is a Ti AIC26 CODEC: powered up or down (i.e. Hi Z ports) makes no difference. Does SPI need a MISO return to function?
3.) All P0_x ports configured as pull ups, this applies to GPIOs. I assumed it still applies to ports configured as peripherals. Is this my mistake?

I have tried all P0_ ports set as GPIO ouputs and confirmed PWB wiring, logic analyzer test points and nothing holding the pins low. I am using the IAR IDE.

5 long days I am out of things to try, except adding pull ups, not optimistic since debug reg U1DBUF stays 0x00.

I really appreciate any help you can provide.

SFR labels used above and reg tables can be found in the CC1110 spec at http://focus.ti.com/lit/ds/symlink/cc1110f32.pdf The CC111x is SW compatable with the CC251x.
 
Last edited by a moderator:

Thread Starter

Hamilton

Joined Jun 20, 2008
10
I tacked on three 10K pull up resistors this morning to MOSI, MISO, and SCLK. CS (SS) did not require one since it is a GPIO configured with a PU. Still no serial data. SCLK remain low which is idle given CPOL = 0
 

Thread Starter

Hamilton

Joined Jun 20, 2008
10
The app note is for the CC1100 like parts which do not have a internal MCU and are slaves.

The Ti radio parts with a MCU (CC111x, CC251x, CC2430, etc) have several good app notes and reference designs none of which address external interfaces including SPI. I did get some code from a Ti support engineer that is a help but not a complete answer. My formal request to Ti from 5/13 has not been answered which is normal.
 

junkshow

Joined Jun 25, 2008
1
I'm having the same problem with the SPI on the CC2511. I'm using USART0 Alt 1, with pretty much the same initialization steps, and getting the same result (SCK does nothing). If I figure it out, I'll let you know, but based your experience, I think I'll probably just end up implementing a bit-banged SPI and scrapping the USART.
 

Thread Starter

Hamilton

Joined Jun 20, 2008
10
If I find anything I will put it here and send you a PM. If you develop a good B'bang solution I would like to use it. I only need load a dozen regs in a CODEC. I have a what looks like a good Ti AN for the I2S interface where the real data flows.

Its ashame that we can not get Ti to return messages. The Ti office that handles this is local to me here in NH.
 

roddefig

Joined Apr 29, 2008
149
Hello.

I just wanted to mention that I sympathize with you guys. Two years ago I had no end of trouble with getting a CC2420 to function properly. Tech support from TI was abysmal. We eventually ended up going with a two-chip solution from Atmel.

It's rather sad because apparently Chipcon used to be a great company before they were swallowed by TI.

I wish you both the best of luck.
 
Hello people,

I have just begun to work with this transceiver and I got scared after read this, but then, as always I thought... do you really think that TI would sell this device with such an error...??? I have type this code and fortunately it has work from the first try. I hope it helps you.

I use the "UART0" at the "Alternative Location 2" and my crystal clock is 27MHz one... so...

Rich (BB code):
// Project: ... Almendron's Project

#include "ioCC1110.h"
#include "hal_defines.h"

#define LED10        P1_0    // LED diode 0
#define LED11        P1_1    // LED diode 1

#define SPI_SSn        P1_2    // SPI !(Slave Select)
#define SPI_CLK        P1_3    // SPI Clock
#define SPI_MISO    P1_4    // SPI Master In. Slave Out.
#define SPI_MOSI    P1_5    // SPI Master Out. Slave In.

#define DI_20        P2_0    // Hall digital input

// Variables
unsigned char SPI_Tx = 0, SPI_Rx = 0;

int main( void ) {
  // ======== OSCILLATOR Config. ========
  CLKCON = 0x80;    // CLKCON = 10000000; System Clk Osc = XOSC
  while(!(SLEEP&0x40));    // waiting until XOSC powered up & stable
  asm("NOP");        // small wait
  SLEEP |= 0x04;    // osc. not selected powered down

  // ======== IOs Config. ========
  // --- Digital Inputs ---
//  DI_20 = x;         // Port 2.0 = x        Hall Sensor Input
  P2DIR &= ~0x01;    // Port 2.0 Dir = 0 (In)
  P2SEL &= ~0x01;    // Port 2.0 Sel = 0 (GP)
  P2INP |= 0x01;    // Port 2.0 PU/PD = Disable

  // --- Dig. Outputs ---
  LED10 = 1;        // Port 1.0 = 1         LED0 = off
  P1DIR |= 0x01;    // Port 1.0 Dir = 1 (Out)
  P1SEL &= ~0x01;    // Port 1.0 Sel = 0 (GP)

  LED11 = 1;        // Port 1.1 = 1         LED1 = off
  P1DIR |= 0x02;    // Port 1.1 Dir = 1 (Out)
  P1SEL &= ~0x02;    // Port 1.1 Sel = 0 (GP)

  // --- SPI Bus ---
  SPI_SSn = 1;        // Port 1.2 = 1     SPI Slave Select not selected
  P1DIR |= 0x04;    // Port 1.2 Dir = 1 (Out)
  P1SEL &= 0x04;    // Port 1.2 Sel = 1 (GP)

//  SPI_CLK = x;    // Port 1.3 = x        SPI Clock = x form SPI Clock
  P1DIR |= 0x08;    // Port 1.3 Dir = 1 (Out)
  P1SEL |= 0x08;    // Port 1.3 Sel = 1 (Peripheral... but which one???)
  
//  SPI_MISO = x;    // Port 1.4 = x        SPI MISO = x from SPI Slave
  P1DIR &= ~0x10;    // Port 1.4 Dir = 0 (In)
  P1SEL |= 0x10;    // Port 1.4 Sel = 1 (Peripheral... but wich one???)
//  P1INP |= 0x10;    // Port 1.4 PU/PD = Disable
  
//  SPI_MOSI = x;    // Port 1.5 = 0        SPI MOSI = x from U0DBUF reg.
  P1DIR |= 0x20;    // Port 1.5 Dir = 1 (Out)
  P1SEL |= 0x20;    // Port 1.5 Sel = 1 (Peripheral... but wich one???)


  // ======== PERIPHERALS Config. ========
  // UART_0 as SPI_0
  PERCFG |= 0x01;    // PERCFG.U0CFG = 1 (UART 0 Location = Alt. 2)

  U0CSR &= ~0x80;    // UART0 Mode = SPI (def)
  U0CSR &= ~0x20;    // SPI Master = Master (def)
  
  U0GCR &= ~0x80;    // Clock Polarity = Low when IDLE (def)
  U0GCR &= ~0x40;    // Clock Phase = Data centered on 1st edge (def)
  U0GCR &= ~0x20;    // Bit Order = LSB 1st (def)

  U0BAUD = 117;        // Baud Rate = 9604.45 (Err = 0.05%)
  U0GCR |= 8;
  
   // ======== Ini. Main Loop ========
  while( 1 ) {
    while( DI_20 );    // Waiting for DI_20...
    while( !DI_20 );

    SPI_SSn = 0;        // Select Slave
    SPI_Tx = 0x55;        // Tx an 0x55

    U0DBUF = SPI_Tx;        // Tx <-> Rx...
    while( !(U0CSR&0x02) ); U0CSR &= ~0x02;
    
    SPI_Rx = U0DBUF;        // Rx whatever... (55h in this case)
    
    SPI_SSn = 1;        // Un-select Slave
    
    if( SPI_Rx == SPI_Tx )
        LED10 = ~LED10;

    SPI_Tx = SPI_Rx = 0;
  }  
  // ======== Fin. Main Loop ========
  
  return 0;
}
See you!!
:)
 
Last edited by a moderator:

emot

Joined Sep 14, 2008
2
I hope I can help you.
/***********************************************************/
//将芯片初始化到主/从模式
void INIT_SPI(void)
{
IO_FUNC_PORT_PIN(0,2,IO_FUNC_PERIPH);
IO_FUNC_PORT_PIN(0,3,IO_FUNC_PERIPH);
//IO_FUNC_PORT_PIN(0,4,IO_FUNC_PERIPH);
IO_FUNC_PORT_PIN(0,5,IO_FUNC_PERIPH);
IO_PER_LOC_SPI0_AT_PORT0_PIN2345(); //串口0,位置1
#ifdef SPI_MASTER_MODE
SPI_SETUP(0,57600,MY_SPI_M_OPTIONS); //SPI0,57600,
IO_FUNC_PORT_PIN(0,4,IO_FUNC_GIO);
IO_DIR_PORT_PIN(0,4,IO_OUT);
P0_4 = 0;
#else
SPI_SETUP(0,57600,MY_SPI_S_OPTIONS);
IO_FUNC_PORT_PIN(0,4,IO_FUNC_PERIPH);
#endif
INT_ENABLE(INUM_URX0,INT_ON);
INT_ENABLE(INUM_UTX0,INT_ON);
INT_GLOBAL_ENABLE(INT_ON);
}

/**********************************************************************/
//主模式发一字节
void SPI0_M_SEND_BYTE(BYTE data)
{
while(USART0_BUSY());
U0DBUF = data;
while(!USART0_BYTE_TRANSMITTED());
U0CSR &= ~0x02;
}
void SPI0_S_SEND_BYTE(BYTE data)
{
while(USART0_BUSY());
U0DBUF = data;
}
 

umadevi

Joined Dec 17, 2013
1
Hello people,

I have just begun to work with this transceiver and I got scared after read this, but then, as always I thought... do you really think that TI would sell this device with such an error...??? I have type this code and fortunately it has work from the first try. I hope it helps you.

I use the "UART0" at the "Alternative Location 2" and my crystal clock is 27MHz one... so...

// Project: ... Almendron's Project

#include "ioCC1110.h"
#include "hal_defines.h"

#define LED10 P1_0 // LED diode 0
#define LED11 P1_1 // LED diode 1

#define SPI_SSn P1_2 // SPI !(Slave Select)
#define SPI_CLK P1_3 // SPI Clock
#define SPI_MISO P1_4 // SPI Master In. Slave Out.
#define SPI_MOSI P1_5 // SPI Master Out. Slave In.

#define DI_20 P2_0 // Hall digital input

// Variables
unsigned char SPI_Tx = 0, SPI_Rx = 0;

int main( void ) {
// ======== OSCILLATOR Config. ========
CLKCON = 0x80; // CLKCON = 10000000; System Clk Osc = XOSC
while(!(SLEEP&0x40)); // waiting until XOSC powered up & stable
asm("NOP"); // small wait
SLEEP |= 0x04; // osc. not selected powered down

// ======== IOs Config. ========
// --- Digital Inputs ---
// DI_20 = x; // Port 2.0 = x Hall Sensor Input
P2DIR &= ~0x01; // Port 2.0 Dir = 0 (In)
P2SEL &= ~0x01; // Port 2.0 Sel = 0 (GP)
P2INP |= 0x01; // Port 2.0 PU/PD = Disable

// --- Dig. Outputs ---
LED10 = 1; // Port 1.0 = 1 LED0 = off
P1DIR |= 0x01; // Port 1.0 Dir = 1 (Out)
P1SEL &= ~0x01; // Port 1.0 Sel = 0 (GP)

LED11 = 1; // Port 1.1 = 1 LED1 = off
P1DIR |= 0x02; // Port 1.1 Dir = 1 (Out)
P1SEL &= ~0x02; // Port 1.1 Sel = 0 (GP)

// --- SPI Bus ---
SPI_SSn = 1; // Port 1.2 = 1 SPI Slave Select not selected
P1DIR |= 0x04; // Port 1.2 Dir = 1 (Out)
P1SEL &= 0x04; // Port 1.2 Sel = 1 (GP)

// SPI_CLK = x; // Port 1.3 = x SPI Clock = x form SPI Clock
P1DIR |= 0x08; // Port 1.3 Dir = 1 (Out)
P1SEL |= 0x08; // Port 1.3 Sel = 1 (Peripheral... but which one???)

// SPI_MISO = x; // Port 1.4 = x SPI MISO = x from SPI Slave
P1DIR &= ~0x10; // Port 1.4 Dir = 0 (In)
P1SEL |= 0x10; // Port 1.4 Sel = 1 (Peripheral... but wich one???)
// P1INP |= 0x10; // Port 1.4 PU/PD = Disable

// SPI_MOSI = x; // Port 1.5 = 0 SPI MOSI = x from U0DBUF reg.
P1DIR |= 0x20; // Port 1.5 Dir = 1 (Out)
P1SEL |= 0x20; // Port 1.5 Sel = 1 (Peripheral... but wich one???)


// ======== PERIPHERALS Config. ========
// UART_0 as SPI_0
PERCFG |= 0x01; // PERCFG.U0CFG = 1 (UART 0 Location = Alt. 2)

U0CSR &= ~0x80; // UART0 Mode = SPI (def)
U0CSR &= ~0x20; // SPI Master = Master (def)

U0GCR &= ~0x80; // Clock Polarity = Low when IDLE (def)
U0GCR &= ~0x40; // Clock Phase = Data centered on 1st edge (def)
U0GCR &= ~0x20; // Bit Order = LSB 1st (def)

U0BAUD = 117; // Baud Rate = 9604.45 (Err = 0.05%)
U0GCR |= 8;

// ======== Ini. Main Loop ========
while( 1 ) {
while( DI_20 ); // Waiting for DI_20...
while( !DI_20 );

SPI_SSn = 0; // Select Slave
SPI_Tx = 0x55; // Tx an 0x55

U0DBUF = SPI_Tx; // Tx <-> Rx...
while( !(U0CSR&0x02) ); U0CSR &= ~0x02;

SPI_Rx = U0DBUF; // Rx whatever... (55h in this case)

SPI_SSn = 1; // Un-select Slave

if( SPI_Rx == SPI_Tx )
LED10 = ~LED10;

SPI_Tx = SPI_Rx = 0;
}
// ======== Fin. Main Loop ========

return 0;
}

See you!!
:)
Hi Almendronman,
CAn you please explain me how do you set baud rate for SPI/

Regards.
 
Top