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.

cc430f6137 communicate with cc1120 TRxEB

Other Parts Discussed in Thread: CC1101, CC1120, CC430F6137, SIMPLICITI

Hi,

I try to send the data of my sensor to cc1120 by cc430f6137 which has a cc1101 based core. That is communicate with Sub-1G.

My sensor's sample rate is 100Hz. It communicate with cc430 by SPI.

At first, the transmission time interval is set at 16 ms.  I use SmartRF with the cc1120 DK and it  receives ok. I observe the transmission time by the time stamp added automatically by SmartRF. Below is the data from SmartRF:

19:35:00.703 | 01 65 00 c5 03 8f  |  -36
19:35:00.719 | 01 65 00 c5 03 a0  |  -36
19:35:00.734 | 01 54 00 c5 03 a0  |  -36
19:35:00.750 | 01 65 00 d6 03 a0  |  -36
19:35:00.765 | 01 65 00 d6 03 8f  |  -36
19:35:00.781 | 01 65 00 c5 03 a0  |  -36
19:35:00.797 | 01 65 00 c5 03 8f  |  -36
19:35:00.812 | 01 54 00 d6 03 8f  |  -36
19:35:00.828 | 01 65 00 d6 03 8f  |  -36
19:35:00.843 | 01 65 00 d6 03 a0  |  -36
19:35:00.859 | 01 65 00 e8 03 a0  |  -36
19:35:00.875 | 01 65 00 e8 03 a0  |  -36
19:35:00.890 | 01 54 00 e8 03 a0  |  -36
19:35:00.906 | 01 54 00 e8 03 8f  |  -36
19:35:00.921 | 01 42 00 e8 03 6b  |  -31
19:35:00.937 | 01 42 00 e8 03 7d  |  -31
19:35:00.953 | 01 30 00 d6 03 8f  |  -31
19:35:00.968 | 01 30 00 c5 03 8f  |  -31
19:35:00.984 | 01 42 00 c5 03 8f  |  -31
19:35:00.999 | 01 30 00 b3 03 7d  |  -31
19:35:01.015 | 01 42 00 c5 03 7d  |  -32
19:35:01.031 | 01 42 01 30 03 7d  |  -32
19:35:01.062 | 01 1e 00 fa 03 8f  |  -32
19:35:01.077 | 01 30 00 e8 03 8f  |  -32

Now, I want to send it with another time interval which means I want to change the sample rate. But when I change the timer to 12ms or 25ms (the range from 10 to 30ms), the time stamp in the SmartRF doesn't change to the corresponding time interval 12 or 25, etc. It is still 16 ms!

When the time interval is 12ms, below is the data from SmartRF:

19:56:04.030 | 00 36 00 7d 03 8f  |  -36
19:56:04.046 | 00 47 00 7d 03 8f  |  -36
19:56:04.061 | 00 36 00 7d 03 8f  |  -36
19:56:04.077 | 00 47 00 7d 03 8f  |  -36
19:56:04.077 | 00 47 00 7d 03 a0  |  -36
19:56:04.092 | 00 36 00 7d 03 a0  |  -36
19:56:04.108 | 00 36 00 7d 03 8f  |  -36
19:56:04.139 | 00 47 00 7d 03 a0  |  -36
19:56:04.155 | 00 47 00 7d 03 8f  |  -36
19:56:04.170 | 00 47 00 7d 03 8f  |  -36
19:56:04.186 | 00 47 00 7d 03 8f  |  -36
19:56:04.186 | 00 47 00 7d 03 8f  |  -36
19:56:04.202 | 00 47 00 7d 03 8f  |  -36
19:56:04.217 | 00 47 00 7d 03 8f  |  -36
19:56:04.233 | 00 47 00 7d 03 8f  |  -36
19:56:04.264 | 00 47 00 7d 03 8f  |  -36
19:56:04.280 | 00 36 00 7d 03 8f  |  -36
19:56:04.295 | 00 36 00 6b 03 a0  |  -36
19:56:04.295 | 00 47 00 7d 03 a0  |  -35
19:56:04.311 | 00 47 00 7d 03 8f  |  -36
19:56:04.326 | 00 47 00 7d 03 8f  |  -36
19:56:04.342 | 00 36 00 7d 03 a0  |  -36
19:56:04.342 | 00 36 00 7d 03 a0  |  -36
19:56:04.389 | 00 47 00 7d 03 8f  |  -36
19:56:04.404 | 00 47 00 6b 03 8f  |  -36
19:56:04.404 | 00 36 00 6b 03 7d  |  -35
19:56:04.420 | 00 47 00 6b 03 a0  |  -36
19:56:04.436 | 00 47 00 6b 03 8f  |  -36
19:56:04.451 | 00 47 00 6b 03 8f  |  -35
19:56:04.451 | 00 47 00 6b 03 8f  |  -36
19:56:04.467 | 00 47 00 7d 03 8f  |  -36
19:56:04.482 | 00 47 00 6b 03 8f  |  -36
19:56:04.498 | 00 47 00 7d 03 a0  |  -36
19:56:04.514 | 00 47 00 7d 03 a0  |  -36
19:56:04.514 | 00 47 00 7d 03 8f  |  -36
19:56:04.529 | 00 47 00 7d 03 8f  |  -36
19:56:04.545 | 00 47 00 6b 03 a0  |  -36
19:56:04.560 | 00 47 00 6b 03 8f  |  -36
19:56:04.560 | 00 47 00 7d 03 8f  |  -36
19:56:04.576 | 00 36 00 7d 03 8f  |  -36

When I set the time interval to 25ms, below is the data from SmartRF:

19:07:41.071 | 00 b3 01 9b 03 6b  |  -33
19:07:41.086 | 00 c5 01 65 03 59  |  -33
19:07:41.117 | 00 b3 01 65 03 6b  |  -33
19:07:41.133 | 00 c5 01 89 03 8f  |  -33
19:07:41.164 | 00 d6 01 89 03 6b  |  -33
19:07:41.195 | 00 c5 01 89 03 6b  |  -33
19:07:41.211 | 00 d6 01 89 03 59  |  -33
19:07:41.242 | 00 b3 01 bf 03 47  |  -33
19:07:41.258 | 00 b3 01 9b 03 7d  |  -33
19:07:41.289 | 00 b3 01 ad 03 7d  |  -33
19:07:41.320 | 00 a1 01 9b 03 6b  |  -33
19:07:41.336 | 00 c5 01 89 03 59  |  -33
19:07:41.367 | 00 c5 01 77 03 59  |  -33
19:07:41.383 | 00 d6 01 9b 03 6b  |  -33
19:07:41.414 | 00 d6 01 89 03 7d  |  -33
19:07:41.445 | 00 d6 01 ad 03 a0  |  -33
19:07:41.461 | 00 d6 01 9b 03 7d  |  -33
19:07:41.492 | 00 d6 01 9b 03 a0  |  -33
19:07:41.507 | 00 c5 01 d1 03 8f  |  -34
19:07:41.539 | 00 d6 01 d1 03 b2  |  -34
19:07:41.570 | 00 fa 01 bf 03 7d  |  -34
19:07:41.585 | 01 0c 01 ad 03 47  |  -34
19:07:41.617 | 01 30 01 ad 03 59  |  -34
19:07:41.632 | 01 30 01 ad 03 6b  |  -34
19:07:41.663 | 01 54 01 9b 03 35  |  -34
19:07:41.695 | 01 65 01 9b 03 11  |  -34
19:07:41.710 | 01 65 01 d1 03 00  |  -34
19:07:41.741 | 01 65 01 f4 02 ee  |  -34
19:07:41.757 | 01 65 01 f4 02 94  |  -34
19:07:41.788 | 01 89 01 f4 02 82  |  -34
19:07:41.819 | 01 9b 01 ad 02 94  |  -34
19:07:41.835 | 01 9b 01 89 02 a6  |  -34
19:07:41.866 | 01 77 01 9b 02 ca  |  -34
19:07:41.882 | 01 42 01 bf 03 00  |  -35
19:07:41.913 | 00 fa 01 f4 03 23  |  -35
19:07:41.944 | 00 d6 01 f4 03 35  |  -35
19:07:41.960 | 00 7d 02 2a 03 11  |  -35

But when I change to 30ms or 50ms or which is bigger than 30, it will be received correctly and the time stamp will change to 30、50 or……

So I wonder why it comes this phonomena like above.

 

And here is my timer.c and  my send function:

// system
#include "project.h"

// driver
#include "timer.h"
#include "ports.h"
#include "buzzer.h"
#include "bmp_as.h"
#include "cma_as.h"
#include "as.h"
#include "bmp_ps.h"
#include "cma_ps.h"
#include "ps.h"
#include "display.h"

// logic
#include "clock.h"
#include "battery.h"
#include "stopwatch.h"
#include "alarm.h"
//#include "altitude.h"
#include "display.h"
#include "rfsimpliciti.h"
//#include "simpliciti.h"
#include "acceleration.h"
//#include "bluerobin.h"
//#include "temperature.h"
#include "sleepmonitor.h"

// *************************************************************************************************
// Prototypes section
void Timer0_Init(void);
void Timer0_Stop(void);
void Timer0_A1_Start(void);
void Timer0_A1_Stop(void);
void Timer0_A3_Start(u16 ticks);
void Timer0_A3_Stop(void);
void Timer0_A4_Delay(u16 ticks);

void (*fptr_Timer0_A3_function)(void);

// *************************************************************************************************
// Defines section

// *************************************************************************************************
// Global Variable section
struct timer sTimer;

// *************************************************************************************************
// Extern section
//extern void BRRX_TimerTask_v(void);
extern void to_lpm(void);

// *************************************************************************************************
// @fn          Timer0_Init
// @brief       Set Timer0 to a period of 1 or 2 sec. IRQ TACCR0 is asserted when timer overflows.
// @param       none
// @return      none
// *************************************************************************************************
void Timer0_Init(void)
{
    // Set interrupt frequency to 1Hz
    TA0CCR0 = 32768 - 1;

    // Enable timer interrupt
    TA0CCTL0 |= CCIE;

    // Clear and start timer now
    // Continuous mode: Count to 0xFFFF and restart from 0 again - 1sec timing will be generated by
    // ISR
    //ACLK,continuous mode  1s
    TA0CTL |= TASSEL0 + MC1 + TACLR;

}

// *************************************************************************************************
// @fn          Timer0_Start
// @brief       Start Timer0.
// @param       none
// @return      none
// *************************************************************************************************
void Timer0_Start(void)
{
    // Start Timer0 in continuous mode
    TA0CTL |= MC_2;
}

// *************************************************************************************************
// @fn          Timer0_Stop
// @brief       Stop and reset Timer0.
// @param       none
// @return      none
// *************************************************************************************************
void Timer0_Stop(void)
{
    // Stop Timer0
    TA0CTL &= ~MC_2;

    // Set Timer0 count register to 0x0000
    TA0R = 0;
}

// *************************************************************************************************
// @fn          Timer0_A3_Start
// @brief       Trigger IRQ every "ticks" microseconds
// @param       ticks (1 tick = 1/32768 sec)
// @return      none
// *************************************************************************************************
void Timer0_A3_Start(u16 ticks)
{
    u16 value = 0;

    // Store timer ticks in global variable
    sTimer.timer0_A3_ticks = ticks;

    // Delay based on current counter value
    // To make sure this value is correctly read
    while (value != TA0R)
        value = TA0R;
    value += ticks;

    // Update CCR
    TA0CCR3 = value;

    // Reset IRQ flag
    TA0CCTL3 &= ~CCIFG;

    // Enable timer interrupt
    TA0CCTL3 |= CCIE;
}

// *************************************************************************************************
// @fn          Timer0_A3_Stop
// @brief       Stop Timer0_A3.
// @param       none
// @return      none
// *************************************************************************************************
void Timer0_A3_Stop(void)
{
    // Clear timer interrupt
    TA0CCTL3 &= ~CCIE;
}

// *************************************************************************************************
// @fn          Timer0_A4_Delay
// @brief       Wait for some microseconds
// @param       ticks (1 tick = 1/32768 sec)
// @return      none
// *************************************************************************************************
void Timer0_A4_Delay(u16 ticks)
{
    u16 value = 0;

    // Exit immediately if Timer0 not running - otherwise we'll get stuck here
    if ((TA0CTL & (BIT4 | BIT5)) == 0)
        return;

    // Disable timer interrupt
    TA0CCTL4 &= ~CCIE;

    // Clear delay_over flag
    sys.flag.delay_over = 0;

    // Add delay to current timer value
    // To make sure this value is correctly read
    while (value != TA0R)
        value = TA0R;
    value += ticks;

    // Update CCR
    TA0CCR4 = value;

    // Reset IRQ flag
    TA0CCTL4 &= ~CCIFG;

    // Enable timer interrupt
    TA0CCTL4 |= CCIE;

    // Wait for timer IRQ
    while (1)
    {
        // Delay in LPM
        to_lpm();               // will also set GIE again

#ifdef USE_WATCHDOG
        // Service watchdog
        WDTCTL = WDTPW + WDTIS__512K + WDTSSEL__ACLK + WDTCNTCL;
#endif
        // Redraw stopwatch display
        if (is_stopwatch())
            display_stopwatch(LINE2, DISPLAY_LINE_UPDATE_PARTIAL);

        // Check stop condition
        // disable interrupt to prevent flag's change caused by interrupt methods
        __disable_interrupt();
        if (sys.flag.delay_over)
            break;
    }
    __enable_interrupt();
}


// *************************************************************************************************
#pragma vector = TIMER0_A0_VECTOR
__interrupt void TIMER0_A0_ISR(void)

{

the code here doesn't have matter to do with my question.

}

// *************************************************************************************************
// *************************************************************************************************
#pragma vector = TIMER0_A1_VECTOR
__interrupt void TIMER0_A1_5_ISR(void)
{
    u16 value = 0;

    switch (TA0IV)
    {
        // Timer0_A1    BlueRobin timer
        case 0x02:             // Timer0_A1 handler
//            BRRX_TimerTask_v();
            break;

        // Timer0_A2    1/1 or 1/100 sec Stopwatch
        case 0x04:             // Timer0_A2 handler
            // Disable IE
            TA0CCTL2 &= ~CCIE;
            // Reset IRQ flag
            TA0CCTL2 &= ~CCIFG;

            if(is_acceleration_measurement())
            {

              Update_pedo_timer(12);//@sz          
              f_readsensor = 1;
            }

            #endif
           
   
            // Enable timer interrupt
            TA0CCTL2 |= CCIE;
            
            break;

        // Timer0_A3    Configurable periodic IRQ (used by button_repeat and buzzer)
        case 0x06:             // Disable IE
            TA0CCTL3 &= ~CCIE;
            // Reset IRQ flag
            TA0CCTL3 &= ~CCIFG;
            // Store new value in CCR
            // To make sure this value is correctly read
            while (value != TA0R)
                value = TA0R;
            value += sTimer.timer0_A3_ticks;
            // Load CCR register with next capture point
            TA0CCR3 = value;
            // Enable timer interrupt
            TA0CCTL3 |= CCIE;
            // Call function handler
            fptr_Timer0_A3_function();

            break;

        // Timer0_A4    One-time delay
        case 0x08:             // Disable IE
            TA0CCTL4 &= ~CCIE;
            // Reset IRQ flag
            TA0CCTL4 &= ~CCIFG;
            // Set delay over flag
            sys.flag.delay_over = 1;
            break;
    }

    // Exit from LPM3 on RETI
    _BIC_SR_IRQ(LPM3_bits);
}

And here is the function of update_pedo_timer

void Update_pedo_timer(u8 value)
{
  // Init CCR register with current time
   TA0CCR2 = TA0R;
   // Load CCR register with next capture time
   TA0CCR2 += CONV_MS_TO_TICKS(value);
}

// Conversion from msec to ACLK timer ticks
#define CONV_MS_TO_TICKS(msec)                          (((msec) * 32768) / 1000)

 

 


main.c 

  while (1)
    {

 if(f_readsensor >=1)  //set this flag in timer
            {
              //getdata from acc sesor
                do_acceleration_measurement();

                sendACCdata2RF();

              f_readsensor = 0;//clear the flag

}

 

 

Please tell why does this situation come and how can I change it?

 

  • The time stamp in SmartRF Studio is set from the PC side, eq when a packet is read from the USB interface. When the interval between packets are short the polling interval on the USB is too long and the timestamp will be inaccurate.

    If you want to check your timer functions I would try to find other methods to measure your timers.
  • Hi TER,

    Do you mean I can set the timestamp in the SmartRF by myself? I thought it is added by the software automatically.

    If the interval between packets are short will lead to the timestamp inaccurate, then why when I set 16ms there is no error? But other settings between 10 ms

    to 30 ms, there will be error. I test for tens of times. Does it have relationship with the polling interval on the USB?

    I debug the timer with ccs and it truly changes to 20ms or 25ms which  value I set. Or maybe my test is wrong……

    Regards,

    Can 

     

  • SmartRF Studio sets the timestamp but based on the timestamp the PC has when a new packet is polled from the USB buffer.

    As you say the change in accuracy could have a variation due to the polling interval. It would be interesting if you got different accuracy if you use a different type of PC.

    But as I wrote the timestamp is not accurate since they are dependent on the PC.
  • Hi TER,

    Ok, what you said I understand. And I just wonder wether my timer has been changed to what I set.Under my circumstances I cannot use the oscilloscope to observe wether it is right or wrong. What I can think of is just using the timestamp to observe or using CCS debugging to observe th time interval between sending the packet. When I debug, it shows right. But the time stamp isn't right. So I am not sure wether I have changed the timer to what I want it be.

    Q1: Do you have any suggestions for me to observe wether I change the timer?

    Q2: I want to get the sample data from the SmartRF.  If the time stamp is not accuracy, can I use the data?

  • You could try the packet sniffer since this uses a different timestamp.

    The data is correct even though the timestamp may be some ms off.
  • Ok, I will have a try using the packet sniffer.
    Thanks very much!