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: CC2530 GPIO code definitions

Part Number: CC2530
Other Parts Discussed in Thread: Z-STACK

Hi Guys!

I working with my device (based on Sample Light w Zstack Z-Stack Home 1.2.2a.44539), w/ a SimpleDescriptionFormat as ZCL Basic On/off, to use 4 GPIO ports (P1_4, P1_5, P0_5 and P0_4), all those have eletric pin avaiable for use. My idea is that when my device received ZCL cmd On/off all those GPIO ports answer (High-1 or Low Level-0, on or off).

To do that i wrote those code in onoffCB funcition:

// Turn on the light 
if ( cmd == COMMAND_ON )
{
zclTeha0002_OnOff = LIGHT_ON;
P1_4 = 1;
P1_5 = 1;
P0_5 = 1;
P0_4 = 1;
P0_3 = 1;
P0_2 = 1;
}
// Turn off the light
else if ( cmd == COMMAND_OFF )
{
zclTeha0002_OnOff = LIGHT_OFF;
P1_4 = 0;
P1_5 = 0;
P0_5 = 0;
P0_4 = 0;
P0_3 = 0;
P0_2 = 0;
}

After my device received the cmd on/off, from the gateway, just P0_5 responds to the commad and changs its level stats ( on-1 and 0ff-0). I didnt not find any code that blocked the another ports  (p1_4, P1_5, P0_4, P0_3 and P0_2).

Anybody have any idea?

BR

Alex

  • Do you also set PxSEL to disable peripheral function and PxDIR to GPO for P1_4, P1_5, P0_5 and P0_4?
  • Hi Mr Yikai, thanks a lot for your assistance!

    I´m using the default DMA configuration (_hal_uart_dma.c) as you can see bellow:

    #if (HAL_UART_DMA == 1)

    #define PxOUT                     P0

    #define PxIN                         P0

    #define PxDIR                      P0DIR

    #define PxSEL                      P0SEL

    .

    .

    .

    #else

    #define PxOUT                    P1

    #define PxIN                         P1

    #define PxDIR                      P1DIR

    #define PxSEL                      P1SEL

    .

    .

    .

    Is this configuration you mentioned?

  • Mr Yikai,
    I found this configuration example on hal_board_cfg.h:

    /* Select peripheral function on I/O pins but SS is left as GPIO for separate control. */\
    P1SEL |= 0xE0; /* SELP1_[7:4] */\
    /* P1.1,2,3: reset, LCD CS, XNV CS. */\
    P1SEL &= ~0x0E; \
    P1 |= 0x0E; \
    P1_1 = 0; \
    P1DIR |= 0x0E; \

    I think is this configuration that you asked me. If is that, please would you can advise me how to set my configuration?
  • You have to use the following code:

    P0SEL &= (~(BV(4)|BV(5)));
    P1SEL &= (~(BV(4)|BV(5)));
    P0DIR |= (BV(4)|BV(5));
    P1DIR |= (BV(4)|BV(5));
  • Mr Yikai,

    on _hal_uart_dma.c or  hal_board_cfg.h ?

    BR

    Alex

  • In your application init function.
  • Hi Mr. Yikai.

    void zclTeha0002_Init( byte task_id )
    {
    zclTeha0002_TaskID = task_id;


    P0SEL &= (~(BV(4)|BV(5)));
    P1SEL &= (~(BV(4)|BV(5)));
    P0DIR |= (BV(4)|BV(5));
    P1DIR |= (BV(4)|BV(5));

    .....

    Now is running very well!

    You are the BEST!

    Thanks a lot!!!!

    BR

    Alex