Ti Chipcon CC1110/CC2510 SPI problem

Discussion in 'Embedded Systems and Microcontrollers' started by Hamilton, Jun 20, 2008.

  1. Hamilton

    Thread Starter Member

    Jun 20, 2008
    10
    0
    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:

    Code ( (Unknown Language)):
    1.  
    2. char addr , value;
    3. addr = 255;
    4. value = 255
    5.  
    6. do {
    7. CODEC_SS_LOW; // /CS enable PIN P0_2
    8. URX1IF = 0; // Clear flag from first dummy byte
    9. U1DBUF = addr; // Send address
    10. TP_ON; // Just a Logic analyzer "marker" using P0_0
    11. while (!UTX1IF); // Wait for TX to finish
    12. TP_OFF; // Just a Logic analyzer "marker" using P0_0
    13. UTX1IF = 0; // Clear TX flag
    14. URX1IF = 0; // Clear RX flag
    15. U1DBUF = value; // Send value
    16. TP_ON; // Just a Logic analyzer "marker" using P0_0
    17. while (!UTX1IF); // Wait for end of data TX
    18. TP_OFF; // Just a LogicPort "marker" using P0_0
    19. UTX1IF = 0; // Clear flag
    20. CODEC_SS_HI; // /CS disable
    21. } while (0);
    22.  
    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: Dec 18, 2013
  2. Hamilton

    Thread Starter Member

    Jun 20, 2008
    10
    0
    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
     
  3. nanovate

    Distinguished Member

    May 7, 2007
    665
    1
  4. Hamilton

    Thread Starter Member

    Jun 20, 2008
    10
    0
    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.
     
  5. junkshow

    New Member

    Jun 25, 2008
    1
    0
    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.
     
  6. Hamilton

    Thread Starter Member

    Jun 20, 2008
    10
    0
    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.
     
  7. roddefig

    Active Member

    Apr 29, 2008
    149
    0
    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.
     
  8. almendronman

    New Member

    Jul 7, 2008
    1
    0
    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...

    Code ( (Unknown Language)):
    1.  
    2. // Project: ... Almendron's Project
    3.  
    4. #include "ioCC1110.h"
    5. #include "hal_defines.h"
    6.  
    7. #define LED10        P1_0    // LED diode 0
    8. #define LED11        P1_1    // LED diode 1
    9.  
    10. #define SPI_SSn        P1_2    // SPI !(Slave Select)
    11. #define SPI_CLK        P1_3    // SPI Clock
    12. #define SPI_MISO    P1_4    // SPI Master In. Slave Out.
    13. #define SPI_MOSI    P1_5    // SPI Master Out. Slave In.
    14.  
    15. #define DI_20        P2_0    // Hall digital input
    16.  
    17. // Variables
    18. unsigned char SPI_Tx = 0, SPI_Rx = 0;
    19.  
    20. int main( void ) {
    21.   // ======== OSCILLATOR Config. ========
    22.   CLKCON = 0x80;    // CLKCON = 10000000; System Clk Osc = XOSC
    23.   while(!(SLEEP&0x40));    // waiting until XOSC powered up & stable
    24.   asm("NOP");        // small wait
    25.   SLEEP |= 0x04;    // osc. not selected powered down
    26.  
    27.   // ======== IOs Config. ========
    28.   // --- Digital Inputs ---
    29. //  DI_20 = x;         // Port 2.0 = x        Hall Sensor Input
    30.   P2DIR &= ~0x01;    // Port 2.0 Dir = 0 (In)
    31.   P2SEL &= ~0x01;    // Port 2.0 Sel = 0 (GP)
    32.   P2INP |= 0x01;    // Port 2.0 PU/PD = Disable
    33.  
    34.   // --- Dig. Outputs ---
    35.   LED10 = 1;        // Port 1.0 = 1         LED0 = off
    36.   P1DIR |= 0x01;    // Port 1.0 Dir = 1 (Out)
    37.   P1SEL &= ~0x01;    // Port 1.0 Sel = 0 (GP)
    38.  
    39.   LED11 = 1;        // Port 1.1 = 1         LED1 = off
    40.   P1DIR |= 0x02;    // Port 1.1 Dir = 1 (Out)
    41.   P1SEL &= ~0x02;    // Port 1.1 Sel = 0 (GP)
    42.  
    43.   // --- SPI Bus ---
    44.   SPI_SSn = 1;        // Port 1.2 = 1     SPI Slave Select not selected
    45.   P1DIR |= 0x04;    // Port 1.2 Dir = 1 (Out)
    46.   P1SEL &= 0x04;    // Port 1.2 Sel = 1 (GP)
    47.  
    48. //  SPI_CLK = x;    // Port 1.3 = x        SPI Clock = x form SPI Clock
    49.   P1DIR |= 0x08;    // Port 1.3 Dir = 1 (Out)
    50.   P1SEL |= 0x08;    // Port 1.3 Sel = 1 (Peripheral... but which one???)
    51.  
    52. //  SPI_MISO = x;    // Port 1.4 = x        SPI MISO = x from SPI Slave
    53.   P1DIR &= ~0x10;    // Port 1.4 Dir = 0 (In)
    54.   P1SEL |= 0x10;    // Port 1.4 Sel = 1 (Peripheral... but wich one???)
    55. //  P1INP |= 0x10;    // Port 1.4 PU/PD = Disable
    56.  
    57. //  SPI_MOSI = x;    // Port 1.5 = 0        SPI MOSI = x from U0DBUF reg.
    58.   P1DIR |= 0x20;    // Port 1.5 Dir = 1 (Out)
    59.   P1SEL |= 0x20;    // Port 1.5 Sel = 1 (Peripheral... but wich one???)
    60.  
    61.  
    62.   // ======== PERIPHERALS Config. ========
    63.   // UART_0 as SPI_0
    64.   PERCFG |= 0x01;    // PERCFG.U0CFG = 1 (UART 0 Location = Alt. 2)
    65.  
    66.   U0CSR &= ~0x80;    // UART0 Mode = SPI (def)
    67.   U0CSR &= ~0x20;    // SPI Master = Master (def)
    68.  
    69.   U0GCR &= ~0x80;    // Clock Polarity = Low when IDLE (def)
    70.   U0GCR &= ~0x40;    // Clock Phase = Data centered on 1st edge (def)
    71.   U0GCR &= ~0x20;    // Bit Order = LSB 1st (def)
    72.  
    73.   U0BAUD = 117;        // Baud Rate = 9604.45 (Err = 0.05%)
    74.   U0GCR |= 8;
    75.  
    76.    // ======== Ini. Main Loop ========
    77.   while( 1 ) {
    78.     while( DI_20 );    // Waiting for DI_20...
    79.     while( !DI_20 );
    80.  
    81.     SPI_SSn = 0;        // Select Slave
    82.     SPI_Tx = 0x55;        // Tx an 0x55
    83.  
    84.     U0DBUF = SPI_Tx;        // Tx <-> Rx...
    85.     while( !(U0CSR&0x02) ); U0CSR &= ~0x02;
    86.    
    87.     SPI_Rx = U0DBUF;        // Rx whatever... (55h in this case)
    88.    
    89.     SPI_SSn = 1;        // Un-select Slave
    90.    
    91.     if( SPI_Rx == SPI_Tx )
    92.         LED10 = ~LED10;
    93.  
    94.     SPI_Tx = SPI_Rx = 0;
    95.   }  
    96.   // ======== Fin. Main Loop ========
    97.  
    98.   return 0;
    99. }
    100.  
    See you!!
    :)
     
    Last edited by a moderator: Dec 18, 2013
  9. emot

    New Member

    Sep 14, 2008
    2
    0
    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;
    }
     
  10. umadevi

    New Member

    Dec 17, 2013
    1
    0
    Hi Almendronman,
    CAn you please explain me how do you set baud rate for SPI/

    Regards.
     
  11. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    You think someone that hasn't been on for 5 years and has a single post is coming back?:p
     
  12. MrChips

    Moderator

    Oct 2, 2009
    12,449
    3,365
    You are not likely to get a response considering the date of the post.

    The baud is set by the statement

    U0BAUD = 117;
     
Loading...