• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Low Power RF & Wireless Connectivity » Low Power RF Hardware & Tools Forum » CC2510 spi interface problem
Share
Low Power RF & Wireless Connectivity
  • Forums
  • Announcements
  • Files
  • E2E Wiki
Options
  • Subscribe via RSS

CC2510 spi interface problem

CC2510 spi interface problem

This question is answered
LJT
Posted by LJT
on Apr 30 2012 18:50 PM
Prodigy145 points

Hello Texas Instruments!

I am having problems configuring a CC2510 for SPI.  I would like to use the CC2510 as the master device.  I am having trouble seeing a serial clock signal (SCK) on the oscilloscope on P1_5 (SCK).  I am also having trouble toggling P1_6 (MOSI) with a simple toggle example in the code.  Does anyone see a problem with my code regarding why I can not toggle P1_6 and why I don't see a serial clock signal on P1_5?

Is it necessary to put data on the UxDBUF, in order for a serial clock signal to appear on P1_5?  The reason why I ask this question is that I have peripheral devices that require a SCK all of the time.

Note:  Comment the forever for loop out when testing other parts of the program not related to toggling P1_6.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 

#define BUFFER_SIZE 0x05

static uint8 txBufferMaster[BUFFER_SIZE];

int main(void)

 {

uint8 value = 0x00;    

int i;    

for (i = 0; i< BUFFER_SIZE; i++)    

 {        

txBufferMaster[i] = value++;    

 }

// Configure USART1 for Alternative 2 location => Port P1 (PERCFG.U1CFG = 1)    

PERCFG |= 0x02;    //PERCFG.U1CFG = 1        

P1SEL |= 0xE0;    //P1_7, P1_6, and P1_5 are set up as peripherals    

P1SEL &= ~0x1F;   //P1_4, P1_3, P1_2, P1_1, P1_0 are set up as general purpose I/O    

P1DIR |= 0x1D;    //P1_4 is output, P1_3 is output, P1_2 is output,                      

//P1_1 is input, P1_0 is output    

P2SEL |= 0x40;    //Give priority to USART1 over USART0 for port 1 pins                      

 //Give priority to USART1 over Timer 3 for port 1 pins                      

//Give priority to Timer 1 over Timer 4                      

//Give priority to USART0 over Timer 1

for (;;)    

 {        

 volatile unsigned int i; // volatile to prevent optimization        

 P1_6 ^= 0x01; // Toggle P1_6 using exclusive-OR        

i = 10000; // SW Delay        

do i--;        

while (i != 0);

}

/* Configure SPI1     

*/        

SLEEP &= ~SLEEP_OSC_PD;    

while(!(SLEEP & SLEEP_XOSC_S));   //monitor XOSC stable status bit    

CLKCON = 0x00; //select HS crystal oscillator & system clock source to 26 Mhz

// Set USART to SPI mode and Master mode        

U1CSR &= ~0xA0;

// Set Baud Rate (SCK frequency) equal to 9596 bps for a 26 MHz system clock    

// (high speed crystal oscialltor)       

U1BAUD = 0x83;    // BAUD_M = 131    

U1GCR |= 0x08;    // BAUD_E = 8

// - negative clock polarity (SCK low when idle)    

// - clock phase for data centered on second edge of SCK period    

// - bit order for transfers to MSB first        

U1GCR |= 0x60;    // CPOL = 0, CPHA = 1, ORDER = 1

/* Transfer data      */

// Set SSN to active low        

P1_4 = 0;

for (i = 0; i < BUFFER_SIZE; i++)    

{        

// Write byte to USART1 buffer (transmit data)        

U1DBUF = txBufferMaster[i];

        // Check if byte is transmitted        

while(!U1TX_BYTE);

        // Clear transmit byte status        

U1TX_BYTE = 0;    

}

// Set SSN to active high    

P1_4 = 1;

// When finished transmitting, set green LED    

P1_0 = 0;   // Set SRF04EB LED1

         return 0;

}

 

 

CC2510 SPI SimpliciTI 2.4GHz C programming spi clock toggle i/o
Report Abuse
  • Reply
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
All Replies
  • M
    Posted by M
    on May 03 2012 02:20 AM
    Verified Answer
    Verified by LJT
    Expert7215 points

    You will only have the clock output form the SPI master when you write a byte to the SPI bus, i.e. when the master pushes out whatever byte you have written to UxDBUF. If your slave device needs an SPI clock that runs continuously, you would need to feed UxDBUF with dummy bytes. This doesn't sound like a common SPI slave device, though so using the SPI peripheral might complicate things a bit for you. Maybe bit-banging makes things easier?

    In the code, you try to toggle P1.6 (use it as a GPIO), but that pin is configured as a peripheral signal (function depending on what peripheral unit it is hooked up to internally), so you can't control it as a GPIO.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • LJT
    Posted by LJT
    on May 03 2012 13:51 PM
    Prodigy145 points

    M,

    Thank you for your response.

    Is there an alternative to bit banging?  We are anticipating polling the slave device (writing a byte to the U1DBUF register which will be moved to MOSI and receiving a response from MISO which will be moved to the U1DBUF register simultaneously) often enough to pick up any changes on the input from the slave device.

    Is the only way to test if P1_6 is working as MOSI is to write a byte to U1DBUF?

    Thank you in advance,

    Jim

    CC2510 SPI SimpliciTI mosi miso toggle i/o peripherals SCK U1DBUF
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • M
    Posted by M
    on May 04 2012 00:44 AM
    Verified Answer
    Verified by LJT
    Expert7215 points

    You don't have to use bit banging. My only concern was that you said that you needed to provide a clock all the time to the peripheral device. Continuously polling will most probably work, as this will activate the clock signal for each byte you're reading.

    And yes - the only way to test P1.6 when configured as MOSI is to write to U1DBUF.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • TA12012
    Posted by TA12012
    on May 13 2012 21:00 PM
    Expert8395 points

    Did you solve you issue?

    You need to change your 

    for (;;)    

     {        

     volatile unsigned int i; // volatile to prevent optimization        

     P1_6 ^= 0x01; // Toggle P1_6 using exclusive-OR        

    i = 10000; // SW Delay        

    do i--;        

    while (i != 0);

    }

    to something that actually sends data out using the SPI peripheral.

    Regards
    /TA 

    ---------------------------------------------------------------------------------------------------------
    Please click the Verify Answer
     button on this post if it answers your question.
    ---------------------------------------------------------------------------------------------------------

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • LJT
    Posted by LJT
    on May 15 2012 14:23 PM
    Prodigy145 points

    Sorry,

     

    Reposted this question as a new post.

     

    LJT

    CC2510 SPI CLOCK debugger IAR EW C programming SCK master slave step through
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • LJT
    Posted by LJT
    on May 15 2012 14:35 PM
    Prodigy145 points

    TA12012,

     

    I have been able to generate an output on P1_6 by writing bytes to the U1DBUF register.  However, I am having problems with stepping through my code so I can examine variables and registers within IAR EW and still generate a serial clock output.  Please see my most recent post including source code regarding this issue.  Can you offer any suggestions?

    http://e2e.ti.com/support/low_power_rf/f/155/t/188708.aspx

    Thank you for your help,

    LJT 

    CC2510 SPI CLOCK debugger C programming SCK master slave
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
TI E2E™ Community
  • Support Forums
  • Blogs
  • Videos
  • Groups
  • Site Support & Feedback
  • Settings
TI E2E™ Community Groups
  • TI University Program
  • Make the Switch
  • Microcontroller Projects
  • Motor Drive & Control
Other Communities
  • Deyisupport
  • Designsomething.org
  • beagleboard.org
  • TI on Element 14
  • TI on TechXchangeSM
Other Technical & Support Resources
  • WEBENCH® Design Center
  • Product Information Centers
  • Technical Documents
  • TI Design Network
  • TI Technical Articles
  • TI Training

All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
embedded processors, along with software, tools and the industry’s largest sales/support staff.

© Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy Policy | Terms of Use