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.

CC2541: develop Custom services with CC2541

Part Number: CC2541
Other Parts Discussed in Thread: CC2540

Hlw Sir,

Currently i can send 8 bit data from mobile app to CC2541 using simple BLE peripheral project.

Now, i wants to send 32 bit Data from APP to CC2541. What should i do for that in Simple BLE Peripheral Project.

Please suggest....

  • Hi,

    You can refer to following discussion.
    e2e.ti.com/.../2019677
  • Hi Piyush,

    Please see the Software Developers Guide for resources on this topic: http://www.ti.com/lit/swru271
  • Hlw Sir,

    i can easily generate PWM from TIMER 1.

    But i want simultaneously output from the Channel 1,2,3 of TIMER1.

    I get output either from channel 0,1 or from channel 2,3 as i have to set Priority for output either for Channel 0,1 or for channel 2,3 of TIMER1 in P2DIR register.

    Please suggest......... 

  • Hello Piyush Kumar96,
    Do you use P0?
    What if you try to set P2DIR.PRIP0 to 0 and then set USART 0/1 to Alternative 2 location?

    Please refer to "Table 7-1. Peripheral I/O Pin Mapping" in CC2541 User's Guide (SWRU191F).
  • Hlw Sir,

    I could not understand what you trying to say.

    Can you please elaborate what you wants to say.

    Thank you............

  • Hello,
    I am not very familiar with the use of Timer1/PWM, but if you study "Table 7-1. Peripheral I/O Pin Mapping" it seems possible to make sure all the channels are used if both UART are set to alternate 2. Please refer to PERCFG (0xF1) – Peripheral Control.
  • Hello Sir,

    Very sorry for creating this confusion. That TIMER1 issue was resolved.

    Now, Currently i can send 8 bit data from mobile app to CC2541 using simple BLE peripheral project.

    Now, i wants to send 32 bit Data from APP to CC2541. What should i do for that in Simple BLE Peripheral Project.

    Please suggest....
  • Hello,
    You can refer to Simple Profile Characteristic 5 in the Simple Peripheral example. You can change it to send notifications as well.
  • Hello Sir,

    I use characteristic 3 to send data and also wants to send 32 bits data through this.

    what changes do i with Characteristic 3, So that i can send 32 bit data.
  • You need to update simpleProfileAttrTbl, simpleProfile_WriteAttrCB, simpleProfile_ReadAttrCB, SimpleProfile_GetParameter, SimpleProfile_SetParameter. Refer to how those function handle CHAR5 which is an array of 5 bytes.
  • Hlw Mr Eirik,

    Thanks a lot for your valuable suggestion.

    Now, i can get PWM from channel 1,2,3 of TIMER1.

    But the issue is that when i change the duty cycle of channel 1 PWM then simultaneously change the duty cycle of other two channel.

    please suggest !!!!
  • How do you change the duty cycle?

  • Hlw sir,

    i put the desired value of duty cycle in T1CC1L, T1CC1H for channel 1 and so on .

    And put value in T1CC0L,T1CC0H for PWM signal [ lets say 10 kHz.] 

  • What happens in timer1_ISR?
  • Hlw Sir,

    Here i pasted my code for your reference.

    Please check this....

    i called these in performPeriodicTask() of simpleBLEperipheral of project.




    void pwm_oneInit(void)
    {
    #if defined ( CC2540_MINIDK )

    PERCFG &= (~(0x40)); // Select Timer 1 Alternative 1 location
    PERCFG |= 0x03; /// for uart 1 / 0


    T1CTL |= 0x08; //Set Prescaler divider value = Tick frequency /32
    T1CTL |= 0x03; //3 // Timer 3 mode = 3 - Up/Down

    T1CCTL1 &= ~0x40; // Disable channel 1 interrupts
    T1CCTL1 |= 0x04; // Ch0 mode = compare
    T1CCTL1 |= 0x10; // Ch0 output compare mode = toggle on compare





    #endif
    }

    void LIGHTINIT(void)
    {
    #if defined ( CC2540_MINIDK )
    PERCFG &= (~(0x40)); // Select Timer 1 Alternative 1 location
    PERCFG |= 0x03; /// for uart 1 / 0


    T1CTL |= 0x08; //Set Prescaler divider value = Tick frequency /32
    T1CTL |= 0x03; //3 // Timer 1 mode = 3 - Up/Down

    P2DIR |= 0xC0; // PRIORITY FOR TIMER 1 CHANNEL 2/3


    T1CCTL3 &= ~0x40; // Disable channel 3 interrupts
    T1CCTL3 |= 0x04; // Ch0 mode = compare
    T1CCTL3 |= 0x10; // Ch0 output compare mode = toggle on compare

    //T1CTL |= 0x08; //Set Prescaler divider value = Tick frequency /32





    #endif
    }

    void lightInit(void)
    {


    PERCFG &= (~(0x40)); // Select Timer 1 Alternative 2 location
    PERCFG |= 0x03; /// for uart 1 / 0


    T1CTL |= 0x08; //Set Prescaler divider value = Tick frequency /32
    T1CTL |= 0x03; // Timer 3 mode = 3 - Up/Down

    P2DIR |= 0xC0; // PRIORITY FOR TIMER 1 CHANNEL 2/3

    T1CCTL2 &= ~0x40; // Disable channel 0 interrupts
    T1CCTL2 |= 0x04; // Ch0 mode = compare
    T1CCTL2 |= 0x10; // Ch0 output compare mode = toggle on compare




    }

    uint8 pwm_onestart(uint16 frequency)
    {
    #if defined ( CC2540_MINIDK )
    pwm_oneInit();


    P0SEL |= 0x08;


    T1CC0L = 50; // PWM signal period
    T1CC0H = 0;

    T1CC1L = frequency; // PWM duty cycle
    T1CC1H = 0;




    #endif

    return 1;
    }

    uint8 LIGHTSTART(uint16 dutyCycle)
    {
    #if defined ( CC2540_MINIDK )
    lightInit();



    P0SEL |= 0x10;


    T1CC0L = 50; // PWM signal period
    T1CC0H = 0;

    T1CC2L = dutyCycle; // PWM duty cycle
    T1CC2H = 0;



    return 1;
    #endif
    }
    uint8 lightStart(uint16 DutyCycle)
    {
    #if defined ( CC2540_MINIDK )
    LIGHTINIT();

    P0SEL |= 0x20;

    T1CC0L = 50; // PWM signal period
    T1CC0H = 0;


    T1CC3L = DutyCycle; // PWM duty cycle
    T1CC3H = 0;


    return 1;
    #endif
    }
    void lightstop(void)
    {
    #if defined ( CC2540_MINIDK )

    P0SEL &= ~BV(4);
    P0SEL &= ~BV(5);
    P0_4 = 0;
    P0_5 = 0;

    #endif

    }
    void LIGHTSTOP(void)
    {
    #if defined ( CC2540_MINIDK )
    //T3CTL &= ~0x10; // Stop timer 3
    P0SEL &= ~BV(3);
    P0_3 = 0;
    #endif
    }

  • Piyush,
    Please try to only use code for one channel at a time and test again. In your code you change several channels. Also search for timer1_ISR in your project to figure out what the interrupt routine does. If you still don't figure it out, please post a "Ask a related question" (see top right) and describe the last issue only. Describe exactly how you change the duty cycle only. Thanks.