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: GPIO pins value set

Part Number: CC2530


hello,

I am using CC2530PA1 modules with the datasheet attached below. I want to control GPIO pins and set them high or low to turn a couple of LEDs on or off.

foe example I write the codes like:

P0_1 = 1;
P0_2 = 0;
P0_3 = 1:
P0_4 = 0;

but nothing happens!!!

where is the problem?

also, I want to have a 10ms delay. what should I do? 

is there any library needed? i wand to write it in my event loop.

I use ZStack 3 and temperature sensor sample app1106.RL-CC2530-PA1 English V1.1.pdf

  • Hello shahriar,

    Please refer to hal_board_cfg.h to understand how to initialize and control pins, for example the P0DIR will need to be set for GPIO outputs.  You will also need to be sure that these pins are not already used by other pre-determined functions such as pushbuttons or a communication protocol.  For incorporating delays you can further look into ZDApp.c or bdb.c which demonstrate several osal timers.

    Regards,
    Ryan

  • 1. You have to make sure you config P0SEL and P0DIR correctly to GPO function, which you can refer to CC2530 user guide.

    2. You can use osal_start_timerEx to create a timer event that is triggered 10 ms later. Or, you can use the following function to do 10 ms delay.

    /**************************************************************************************************
     * @fn      HalLcd_HW_WaitUs
     *
     * @brief   wait for x us. @ 32MHz MCU clock it takes 32 "nop"s for 1 us delay.
     *
     * @param   x us. range[0-65536]
     *
     * @return  None
     **************************************************************************************************/
    void HalLcd_HW_WaitUs(uint16 microSecs)
    {
      while(microSecs--)
      {
        /* 32 NOPs == 1 usecs */
        asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop");
        asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop");
        asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop");
        asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop");
        asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop");
        asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop");
        asm("nop"); asm("nop");
      }
    }