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.

CC2530 PWM and pin usage

Other Parts Discussed in Thread: CC2530, DRV8870

I have found some code across the E2E for using PWM to control a motor while variable names and procedure call documentation seems lacking from proper programming standards the main thing that I can find is issues with conflicting pin usage so what I am looking for simple guide for pin usage.  I know from working with other microcontrollers there can be issues with pin groups due to timers or priority.  So below is my basic setup and I am trying to see if there is something to help the proper pin choice. (sample code would be useful I have been trying to dig through the examples for the that are recommended by the CC2530 documentation but for things like the light switch they reference the hal_led.c that instead of using pin commands for the CC2530 it references the four LEDs on the RF05 board this makes it hard to learn from this code to use it as a base for development  it appears all the example code is just to develop the RF05 board but not for the CC2530 itself the example code for example in the hal_led.c should call out a GPIO pin on the CC2530 with how to set it as an ouput, and how to turn it on and off.  If this was instead CC253X_led.c where the code is a simple set of instructions SetGPIO(pin, input/output) WriteGPIO(pin, on/off), ReadGPIO(pin, Value) this would be a much more useful example. Similar if there was a PWM set of code that has SetMotorPWM(pin 1, pin 2) WriteMotorPWM(pin 1, pin 2, %dutycycle, direction)

Pin Configuration

Simple RF receive and transmit

UART - receive data messages

single input (min 58 micro second pulse width) to run interrupt scrip 

two pins for PWM for motor control using DRV8870 chip

13 pins for simple output control LED or similar

  • You can check CC2530 PWM examples in sunmaysky.blogspot.tw/.../how-to-output-pwm-from-cc2530.html and also refer to CC2530 user guide at www.ti.com/.../swru191f.pdf
  • I have looked at the user guide and a lot of the other documents you have and while they have a lot of technical data they are missing the why or how. Below is the code from the blog and it is similar to most of the other code I can find on the PWM but there is no useful documentation. The in line comment says the Code gives priority to timer 1 the problem with this is if I am using a UART stream, a RF stream, and an Interrupt on another pin will changing priority affect how these other parts of the program. That is the type of documentation that is missing.

    Additionally will this code work properly for a two pin output to control a standard Hbridge to control a motor.

    PERCFG |= BV(6); // Select Timer 1 Alternative 2 location
    P2DIR = (P2DIR & ~0xC0) | 0x80; // Give priority to Timer 1
    P1SEL |= BV(1); // Set P1_1 to peripheral

    T1CC0L = 0x3A; // PWM signal period
    T1CC0H = 0x01;

    T1CC1L = 0x9D; // PWM duty cycle
    T1CC1H = 0x00;

    T1CCTL1 = 0x1c;

    T1CTL |= (BV(2)|0x03); // divide with 128 and to do i up-down mode
  • That code only output PWM to P1.1. You can revised on it to make two PWM output.