Due to the U.S. Thanksgiving holiday, please expect delayed responses during the week of 11/22.

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.

CC2510-CC2511DK spi_ex0_master.c source file

Other Parts Discussed in Thread: CC2510, CC2510-CC2511DK

All of these software questions are in regards to the CC2510-CC2511DK.  As a note, when you open the spi_cc2510.eww file, in the following path folder: cc1110_cc2510_Basic Software_Examples\ide\iar\examples\spi, within IAR EW 7.60 there are several software examples demonstrating the SPI peripheral functionality.  These questions are in regards to that example software:  

1. In regards to the spi_ex0_master.c source file, where is U0GCR SFR first initialized in the source code?

2. In regards to the spi_ex0_master.c source file, can you explain the meaning of the following algorithm:
U0GCR = (U0GCR & ~(U0GCR_BAUD_E | U0GCR_CPOL | U0GCR_CPHA | U0GCR_ORDER))
                            | SPI_BAUD_E;

3. In regards to the spi_ex0_master.c source file, can you explain the following line of code and why is it necessary? 
(I never found a write up about why you would write a 1 to a particular port register, eg. P0, P1, P2)

 P1_0=1; P1_3=1;

  • Here are a few preliminary pointers. Further investigation ongoing.

    1. Have a look in ioCCxx10_bitdef.h which contains the bit definitions of registers in CCxx10. Here can be found:

    // U0GCR (0xC5) - USART 0 Generic Control

    #define U0GCR_CPOL                        0x80

    #define U0GCR_CPHA                        0x40

    #define U0GCR_ORDER                       0x20

    #define U0GCR_BAUD_E                      0x1F

    #define U0GCR_BAUD_E0                     0x01

    #define U0GCR_BAUD_E1                     0x02

    #define U0GCR_BAUD_E2                     0x04

    #define U0GCR_BAUD_E3                     0x08

    #define U0GCR_BAUD_E4                     0x10

     

    2.    From the comments in the file it sets the following for the USART0:

        // Set:

        // - mantissa value

        // - exponent value

        // - clock phase to be centered on first edge of SCK period

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

        // - bit order for transfers to LSB first

        Also have a look at page 156 in the CC2510 data sheet for details about the registers.

     

    3.     From comments in the code it seems it turns on the LEDs on the SmartRF04EB.:

    // Initialize P1_1/3 for SRF04EB LED1/3

        P1SEL &= ~(BIT3 | BIT0);

        P1_0 = 1; P1_3 = 1;

        P1DIR |= (BIT3 | BIT0);

  • I have a follow up question to my question #1. 
    If the ioCCxx10_bitdef.h file contains the bit definitions where U0GCR is first initialized, which line contains the #define for U0GCR?

  • Ed,

    See embeeded answers.

    1. In regards to the spi_ex0_master.c source file, where is U0GCR SFR first initialized in the source code?

    It is defined in the ioCC2510.h header file for the CC2510 MCU core.

    2. In regards to the spi_ex0_master.c source file, can you explain the meaning of the following algorithm:
    U0GCR = (U0GCR & ~(U0GCR_BAUD_E | U0GCR_CPOL | U0GCR_CPHA | U0GCR_ORDER))
                                | SPI_BAUD_E;

    It sets up the UART0 hardware paramaters, like baud rate, modulation type, polarity etc. Please see the users guide for more information.

    3. In regards to the spi_ex0_master.c source file, can you explain the following line of code and why is it necessary? 
    (I never found a write up about why you would write a 1 to a particular port register, eg. P0, P1, P2)

     P1_0=1; P1_3=1;

    It initilizes the LED found on SMARTRF04 as written in the code.

    // Initialize P1_1/3 for SRF04EB LED1/3
        P1SEL &= ~(BIT3 | BIT0);
        P1_0 = 1; P1_3 = 1;
        P1DIR |= (BIT3 | BIT0);

    Thomas