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 Bootloader and app entry point

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

Hello,

I am using zstack for cc2530 and I am trying to run a sample light and sample switch application on cc2530 core module,as I don't have the evaluation board.

My questions are :1- As I am using the only cc2530 core module and the sample code is written according to the evaluation board. So I am getting confused at which port shall I connect the light and switch? Please help me with this.

and 2- is it mandatory to have the bootloader to run the above  mentioned applications?

Sorry if you find these questions silly.

  • 1. I suppose you should revise UI related code in SampleLight_ui.c and SampleSwitch_ui.c to make it.
    2. No, it’s not mandatory to use boot loader if you don’t have to support OTA.
  • Hi Yikai Chen,

    thanks for your reply.
    As you said I read it, what I found in that file is HAL_LED_3 is defined to 0x04.
    So that 0x04 is referred to what? means at what port? and i guess the pin number will be 3 right?
  • That’s just a bit flag used by LED driver. The port/pin of LEDs are defined in hal_board_cfg.h
  • Fine.

    Now I have done hardware connections for sample switch as follows:
    one end of push button switch is to vcc and other end is grounded through 10k resistor. P0_1 is pulled down.

    and for sample light hardware connections are:
    P1_0 is connected to LED's anode through 10k resistor and cathode is grounded.

    Then i have compiled both the sample applications as it is and using flash programmer, I flashed its hex files in to cc2530 core modules through cc debugger.

    I am running both the cc2530 modules using cc debugger only.

    still my led is not toggling at every switch press.

    so what could be the issue?

    please help me with it.

  • Can you elaborate how you configure P0.1 as GPI and read the value as button is pressed?
  • I have not made any changes to the original sample switch application. I have just compiled it as it is and flashed it in the module.

    but in the application, in hal_key.c file they have configured it as follows:

    HAL_KEY_SW_6_SEL &= ~(HAL_KEY_SW_6_BIT); /* Set pin function to GPIO */

    #if ! defined ENABLE_LED4_DISABLE_S1
    HAL_KEY_SW_6_DIR &= ~(HAL_KEY_SW_6_BIT); /* Set pin direction to Input */
    #endif

    this is how they have configured it as a input.

    And reading the value of the pin through HalKeyRead() in which there is statement as
    if (HAL_PUSH_BUTTON1())
    {
    keys |= HAL_KEY_SW_6;
    }
  • Do you define ISR_KEYINTERRUPT in project predefined symbols?
  • It wasn't defined. but even after defining it, its not working.

    what could be the possible errors sir?
  • Try to set a breakpoint in HAL_ISR_FUNCTION( halKeyPort0Isr, P0INT_VECTOR ) and press buttonto see if it hits.

  • ok I will check it.

  • It is in hal_key.c.
  • Hi Yikai Chen,
    I know debugging but haven't done it practically before.

    so please let me know is this the correct way of doing it or not?


    I did it like, first I set a break point at HAL_ISR_FUNCTION() and just initially setup the break point at main too.
    then I ran it when I saw the arrow was at main.

    then if I press a button should it jump to that ISR??

  • You have to press “F5” to run the program and then it should hit the breakpoint when you press the button.
  • Even if I do not press the button still it goes inside the HAL_ISR_FUNCTION() and stops at HAL_ENTER_ISR() function.

    and I didn't understood one thing is that, even if I set the breakpoint at HAL_ISR_FUNCTION when I start debugging the breakpoint shifts inside the function and actually the programs halt at HAL_ENTER_ISR() function.
  • Can you do some screenshot to show me what you mean?
  • I am sending you two images.

    1.before starting debugging 2. after starting debugging.

    Important point is I haven't pressed a switch still its going to the ISR.

  • It means there is noise on your P0.1. You should check the button circuit connecting to P0.1.
  • Hi YiKai Chen,

    sorry for replying very late.
    I mistakenly did some wrong connections.
    But now for checking purpose I have put down the LED toggling condition inside halProcessKeyInterrupt function which is working fine.
    and the noise issue may be because I am using the breadboard for testing.
    Still if you help me with the noise issue will help me.

    Thank you for all your help.
  • can you please help me for how to send the commands through air to another cc2530 where I can be able to toggel the LED state.

    what I was actually trying to do is inside the key interrupt only I was trying to use the "zclGeneral_SendOnOff_CmdToggle( SAMPLESW_ENDPOINT, &zclSampleSw_DstAddr1, FALSE, 0 );" command.

    actually it didn' work.

    so what changes I need to do in sample light and sample switch examples code.
    and
    what APIs are used for sending the data over the air?
    Thanks in advance.
  • What is inside your zclSampleSw_DstAddr1?
  • yes it was my mistake I have not provided any values to its members.

    The thing is that in sample code it is actually done in zcl_samplesw.c , but in hurry i declared it there in hal_key.c thinking that its an empty variable. (any way I was thinking something silly that time.)

    but now how can I call "zclGeneral_SendOnOff_CmdToggle( SAMPLESW_ENDPOINT, &zclSampleSw_DstAddr1, FALSE, 0 );" function when my key pressed ISR is getting called?
    because declaring all that parameters again in that file will be very tedious.
  • If there is a key pressed, it would send event and trigger zclSampleSwitch_HandleKeys. I suppose you can call zclGeneral_SendOnOff_CmdToggle in zclSampleLight_HandleKeys if you want a button pressed to send Toggle command.
  • OK and in sample light application what changes I need to make, because I can not see my LED toggling if I press the switch...
  • Do you mean to toggle led on SampleLight when button is pressed on SampleLight?
  • No.
    I have interfaced a button on 1 cc2530 which is programmed with sample switch. so when I press that button interrupt is getting generated and in zclSampleLight_HandleKeys I am sending zclGeneral_SendOnOff_CmdToggle command.
    So, that command will be received by another cc2530 which is programmed with sample light and LED interfaced to this second cc2530 will be toggled.

  • Do you use correct endpoint and destination short address to send zclGeneral_SendOnOff_CmdToggle command?
  • SAMPLESW_ENDPOINT = 8
    and

    zclSampleSw_DstAddr parameters are set as follows in zclSampleSw_Init() function : -
    zclSampleSw_DstAddr.addrMode = (afAddrMode_t)AddrNotPresent;
    zclSampleSw_DstAddr.endPoint = 0;
    zclSampleSw_DstAddr.addr.shortAddr = 0;
  • AddrNotPresent means you intend to use binding table to send command. Do you do binding before you send command?
  • Actually I am not be able to find out whether it has been don in these applications or not.
    Can you please let me know how it could be done.

    Binding means these two applications will be bind together so the command sent by one will be received only by the other bind application right? no need to specify the destination address right?

  • I guess binding can be done by ZDP_BindReq() right?
    In sample application I can not see the above function is getting called any where.

    is commissioning and binding is same?
    beacause in zclSampleLight_Init() functioni there is following function call :
    bdb_RegisterCommissioningStatusCB( zclSampleLight_ProcessCommissioningStatus );

    is that related to binding?
  • I suppose you need to add On/Off cluster into your out cluster of SampleLight and you can send ZDP_BindReq to do binding.
  • How can I add On/Off cluster into out cluster?

    because I can see zclSampleLight_OnOffCB in ZCL General Profile Callback table and on-off cluster attributes in zclSampleLight_Attrs[]. Is that a "in cluster" or a "out cluster"?
  • You should add it into simple descriptor in zcl_aanpleswitch_data.c. By the way, you should read Z-Stack 3.0 Developer’s Guide and ZCL spec to better understand Zigbee protocol.
  • Yah sure I will go through it. I have read it once but I found the cluster concept bit confusing so I decided to do it along with the practical. But I guess I really have to read it neatly once again to have deep knowledge of it.
    sorry for troubling you.

    I will ask if I have any doubts...
  • I also suggest you to study the book “ZigBee Wireless Networks and Transceivers”
  • Ok. Thank you.
  • Hi Yikai Chen,


    In my sample switch application I have In cluster list as
    const cId_t zclSampleSw_InClusterList[] =
    {
    ZCL_CLUSTER_ID_GEN_BASIC,
    ZCL_CLUSTER_ID_GEN_IDENTIFY,
    ZCL_CLUSTER_ID_GEN_ON_OFF_SWITCH_CONFIG
    };
    and out cluster list as
    const cId_t zclSampleSw_OutClusterList[] =
    {
    ZCL_CLUSTER_ID_GEN_IDENTIFY,
    ZCL_CLUSTER_ID_GEN_ON_OFF,
    ZCL_CLUSTER_ID_GEN_GROUPS,
    };

    and in sample light application I have In cluster list as
    const cId_t zclSampleLight_InClusterList[] =
    {
    ZCL_CLUSTER_ID_GEN_BASIC,
    ZCL_CLUSTER_ID_GEN_IDENTIFY,
    ZCL_CLUSTER_ID_GEN_GROUPS,
    ZCL_CLUSTER_ID_GEN_SCENES,
    ZCL_CLUSTER_ID_GEN_ON_OFF
    #ifdef ZCL_LEVEL_CTRL
    , ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL
    #endif
    };

    and as you said I have added out cluster list as
    const cId_t zclSampleLight_OutClusterList[] =
    {
    ZCL_CLUSTER_ID_GEN_ON_OFF
    };

    So please let me know whether my understanding is correct or not?
    when I press the switch, commands in ZCL_CLUSTER_ID_GEN_ON_OFF_SWITCH_CONFIG cluster will go in to the cluster and will come out by converting them to equivalent commands in ZCL_CLUSTER_ID_GEN_ON_OFF. which will be send to the sample light application.
    so the received command at sample light application will receive only those commands if the cluster of the command is present in "Incluster list" (which is in this case ZCL_CLUSTER_ID_GEN_ON_OFF). and to work the sample light application we should declare the ZCL_CLUSTER_ID_GEN_ON_OFF in Outcluster list.

    Is my understanding is correct?

  • Your understanding of adding out cluster list as
    const cId_t zclSampleLight_OutClusterList[] =
    {
    ZCL_CLUSTER_ID_GEN_ON_OFF
    };

    is correct.

    I couldn’t understand your second part of descriptions. Basically, you can use bdb finding and binding to process binding between devices.
  • I am trying to trace the flow of program when I am sending the zclGeneral_SendOnOff_CmdToggle( SAMPLESW_ENDPOINT, &zclSampleSw_DstAddr, FALSE, 0 );

    But now what I have found is that the the above function is actually sending as zcl_SendCommand( (a), (b), ZCL_CLUSTER_ID_GEN_ON_OFF, COMMAND_TOGGLE, TRUE, ZCL_FRAME_CLIENT_SERVER_DIR, (c), 0, (d), 0, NULL )

    So I think its sending COMMAND_TOGGLE which is in ZCL_CLUSTER_ID_GEN_ON_OFF cluster which is not in a sample switch application's InClusterList.
    const cId_t zclSampleSw_InClusterList[] =
    {
    ZCL_CLUSTER_ID_GEN_BASIC,
    ZCL_CLUSTER_ID_GEN_IDENTIFY,
    ZCL_CLUSTER_ID_GEN_ON_OFF_SWITCH_CONFIG
    };

    so is that could be a problem while sending the command?
  • zclGeneral_SendOnOff_CmdToggle sends toggle command to the destination according to destination address and it is nothing to do with zclSampleSw_InClusterList.
  • How can I check whether my module is transmitting or not?
    because in sample switch application I am sending zclGeneral_SendOnOff_CmdToggle( SAMPLESW_ENDPOINT, &zclSampleSw_DstAddr, FALSE, 0 );
    but I am not able to see the command is getting sent in packet sniffer.
  • Do you test on SampleLight as ZC and SampleSwitch as ZED?
  • I was just checking it on sample switch application In which, inside zclSampleSw_HandleKeys I was sending the command and at the same instance for checking purpose I was just toggling the LED just to know whether my program is reaching to the send command or not. So actually it is reaching there but I am not be able to see that on packet sniffer.
  • Do you do binding before you press button to send toggle command?