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.

ZStack SerialApp Example

Other Parts Discussed in Thread: CC2430, Z-STACK

I have two SmartRF04EM boards and the latest versions of ZStack and IAR EW8051.

I cannot seem to get the SerialApp example to operate on either board.  Is this app supposed

to operate straight out of the box, or is there a few tricks to get the app to run?

Thanks for any assistance.

  • The App does run straight out of the box if you use the correct version of IAR.

    I tried to run it with the latest 7.40B instead of the specified EW8051 7.30A.

    Lesson -  Always triple check your version numbers! 

  • The guys were on it.  Happy the issue was resolved! :)

  • It's always the simple things in life that can cause you to over run your deadlines!

     

    I'm trying to turn LED2 on and off in the SerialApp example.

    Do you know why LED2 is shared with LED3 and LED4 with LED1 in the hal_board_cfg.h file?

     I modified the code for LED2 & 4 to mimic the code written for the other two LEDs,

    but the LEDs won't turn on.  Is there another location for activating LED 2 & 4?

  • First, let's answer the 2nd question:  LED2 and LED4 won't turn on because there is no connection to them from the CC2430EM board. Specifically, pins 2 (LED2) and 8 (LED4) on the P1 connector do not connect to any GPIO on the CC2430.

    Now, to answer the 1st question:  Z-Stack provides API for 4 logical LEDs, all of which are used in various sample applications. The developers decided to "remap" the missing logical LEDs to available physical LEDs, as indicated in the hal_board_cfg.h file. This was seen as less confusing than just dropping support for LED2 and LED4.

  • xyzzy said:

    Z-Stack provides API for 4 logical LEDs, all of which are used in various sample applications. The developers decided to "remap" the missing logical LEDs to available physical LEDs, as indicated in the hal_board_cfg.h file. This was seen as less confusing than just dropping support for LED2 and LED4.

    is there any way to add logical leds?

    for example i tried this on hal_board_cfg.h file:

    /* 5 - new led */
    #define LED5_BV           BV(5)
    #define LED5_SBIT         P1_5
    #define LED5_DDR          P1DIR
    #define LED5_POLARITY     ACTIVE_LOW

    and this on GenericApp.c file:

    HalLedBlink ( HAL_LED_5, 3, 50, 1000 );

    but i had this error: HAL_LED_5 is not defined

    does anybody know how to make this work?

    thanks for your help

     

  • Yes, you can add more logical LEDs. You need to add LED5 in several places:

    (1) to clear the error you are seeing, in hal_led.h, you need to:

    add: #define HAL_LED_5 0x10,

    change: #define HAL_LED_ALL (HAL_LED_1 | HAL_LED_2 | HAL_LED_3 | HAL_LED_4 | HAL_LED_5),

    change #define HAL_LED_DEFAULT_MAX_LEDS 5.

     

    (2) to actually toggle a 5th LED, in hal_led.c, in the HalLedOnOff() function, you need to add:

    if (leds & HAL_LED_5)

    {

      if (mode == HAL_LED_MODE_ON)

      {

        HAL_TURN_ON_LED5();

      }

      else

      {

        HAL_TURN_OFF_LED5();

      }

    }

    (3) in hal_led.c, in the HalLedEnterSleep() function, you need to add:

    HalSleepLedState |= HAL_STATE_LED5() << 4;

     

    (4) to avoid new errors when you compile hal_led.c, you must add more code to hal_board_cfg.h:

    #define HAL_TURN_OFF_LED5()  st( LED5_SBIT = LED5_POLARITY (0); )

    #define HAL_TURN_ON_LED5()  st( LED5_SBIT = LED5_POLARITY (1); )

    #define HAL_TOGGLE_LED5()  st( if (LED5_SBIT) { LED5_SBIT = 0; } else { LED5_SBIT = 1;} )

    #define HAL_STATE_LED5()  (LED5_POLARITY (LED5_SBIT))

     

    (5) assuming that P1_5 is available as an output in your configuration, you shold be able to hang a scope on that pin and see it toggle when your program tells it to.

  • thank you very much for your detailed reply

  • Hi,
    thank you it's very helpful.
    I havn't the same Hal of the CC2430DB but I have to program/Debug it with the z-stack and the SmartRf04EB.
    I have to modify it. For the Leds, I will modify the hal_board_cfg.h, hal_led.h, hal_led.c ..

    But I have a problem, how to modify the pin defined of the key??
    in the hal_board_cfg.h, there are Push1 ans push2 configured ;

    / * S1 * /
    # define PUSH1_BV BV (1)
    # define PUSH1_SBIT P0_1
    # define PUSH1_POLARITY ACTIVE_LOW

    / * Joystick * Press Center /
    # define PUSH2_BV BV (0)
    # define PUSH2_SBIT P2_0
    # define PUSH2_POLARITY ACTIVE_HIGH

    I have two buttons that I want to use them to interrupts but I do not know the buttons are set CC2430DB in which pins and what files to SW1 and SW2? what is the difference between push1 and push2 and sw?!

    / * Switches (keys) * /
    # define HAL_KEY_SW_1 0x01 / / Joystick up
    # define HAL_KEY_SW_2 0x02 / / Joystick right
    # define HAL_KEY_SW_5 0x04 / / Joystick center
    # define HAL_KEY_SW_4 0x08 / / Joystick left
    # define HAL_KEY_SW_3 0x10 / / Joystick down
    # define HAL_KEY_SW_6 0x20 / / Button S1 if available
    # define HAL_KEY_SW_7 0x40 / / Button S2 if available

    where can I modify the location pins of Sw1 and Sw2??!!

    tks

  • First, an answer to you 2nd question: on the SmartRF04EB and the CC2430DB, SW1 through SW4 are provided by the joystick (up,right,down,left), PUSH1 is provided the S1 button, and PUSH2 is provided by the joystick (center push).

    Next, to answer your 1st question: SW1 and SW2 (as well as SW3 and SW4) are processed in the HalKeyRead() function in the hal_key.c file. These four switches are provided from the joystick as an analog value, read from the ADC by the call to HalAdcRead().

    Finally, to answer your last question: since you say that you have two buttons that you want to use, it's probably best to replicate the logic for the S1 button (in hal_board_cfg.h) and add those to HalKeyRead() (see the part after #if defined (HAL_KEY_SW_6_ENABLE). When you determine which GPIO will be used for your new buttons, put those in the new button definitions in hal_board.cfg.

    Hope this helps.

  • Hi,

    Thank you,

    but I have an other question;

    I have my smartrf04eb board and i Try to install the usb driver.

    When I specify the C:\Program Files\Texas Instruments\Extras\Drivers when I install the driver, an error message will apear.

    the C:\Program Files\Texas Instruments\Extras\Drivers contains:

    cc2430db, cebal, cebal98, ebinstaller, Srf04dd, srf04eb.

    moon

  • Forgive me, but I'd like to ask a couple of questions -

    What revision of SmartRF04EB are you using? It's pronted on the board.

    What revision of IAR EW8051 are you using?

  • Hi,

    How I have to install the smartrf 2.0.1 rev. When I try to install it, I Check Device Manager for USB conflicts or erroneously installed USB drivers: and I have not an exlamation mark under  “Universal Serial Bus” controllers or “Cebal Controlled Devices”.

  •  Hi,

    Thank you

    In the file hal_board_cfg.h, push1 is defined as a push button and push2 as a joystick.
    but in the hal_key.h

    / * Switches (keys) * /
    # define HAL_KEY_SW_1 0x01 / / Joystick up
    # define HAL_KEY_SW_2 0x02 / / Joystick right
    # define HAL_KEY_SW_5 0x04 / / Joystick center
    # define HAL_KEY_SW_4 0x08 / / Joystick left
    # define HAL_KEY_SW_3 0x10 / / Joystick down
    # define HAL_KEY_SW_6 0x20 / / Button S1 if available
    # define HAL_KEY_SW_7 0x40 / / Button S2 if available

    / * Joystick * /
    # define HAL_KEY_UP 0x01 / / Joystick up
    # define HAL_KEY_RIGHT 0x02 / / Joystick right
    # define HAL_KEY_CENTER 0x04 / / Joystick center
    # define HAL_KEY_LEFT 0x08 / / Joystick left
    # define HAL_KEY_DOWN 0x10 / / Joystick down

    I want to change the pin of the S1

    / * S1 * /
    # define PUSH1_BV    (1)
    # define PUSH1_SBIT  P0_7                 // was P0_1
    # define PUSH1_POLARITY ACTIVE_LOW
     and the

    #define HAL_PUSH_BUTTON1() (PUSH1_POLARITY (PUSH1_SBIT))

    so I change its bit position in hal_key.h
    to
    # define HAL_KEY_SW_6 0x40 / / Button S1 if available
    instead
    # define HAL_KEY_SW_6 0x20 / / Button S1 if available

    and in the Hal_key.c

    #if defined (HAL_KEY_SW_6)
      if (!(HAL_KEY_SW_6_PORT & HAL_KEY_SW_6_BIT)) /* Key is active low */
      {
      keys |= HAL_KEY_SW_6;
      }
    #endif
    hal_key_sw_6 port and hal_key_sw_6  bit are the same with the push1 P0_7???
    and the addition of another button I have the same instructions as for the button S1 to know I can use the  define HAL_KEY_SW_7 of course with the change of its bit position
    ???????

    is PUSH1 button SW6???!!!!!!! where can I configure an other button??!!

     

    For the Leds:

    When I define a new Led in the hal_board_cfg.h :

    #define LED_STATUS2_BV BV(1)
    #define LED_STATUS2_SBIT P1_2
    #define LED_STATUS2_DDR P1DIR
    #define LED_STATUS2_POLARITY ACTIVE_LOW

    I have to modify the bit position in the hal_led.h as;

    #define HAL_LED_STATUS2 0x04        // P1_2 --> 0x04 as P1_0 -->0x01

    ??????

  • Hello,

    I'm new with this technology, and I want to try SerialApp example, but... I don't know how.

    I have two SmartRF04EB 1.9 boards with CC2430 EM 1.2 and I'm using IAR 7.50A/W32 (7.50.1.3)

    I have opened SerialApp project, I have selected CoordinatorEB, I have compiled it and I have sent it to a device. Also I have made the same with EndDeviceEB to another device. I don't know if that is correct !!!

    I have connected every board to a COMM port in my PC, and I have executed 2 hyperterminals

    I'm trying writing in a hyperterminal and I hope to receive text to second hyperterminal.

    I don't have documentation about how to work, steps to try, ...

    Exists this documentation?

    I only have only one simple description about this sample in chapter 3 of document number F8W-2006-0023 (Z-Stack Sample Applications)

    Best regards,

    Carlos

  • Carlos: Are you still having issues getting the SerialApp to run on your platforms?

  • I only need a manual to know how work with this sample. I need keys descriptions

     

    I have another problem with SampleApp: it doesn't work without compiler optimizations.

     

    Thanks

  • Carlos Codina said:

    I only need a manual to know how work with this sample. I need keys descriptions

    The functionality of the keys are as described briefly in the Z-Stack Sample Applications (F8W-2006-0023) document in Chapter 3.  You will find the handling of the keys in the SerialApp_HandleKeys() function.

     

    Carlos Codina said:

    I have another problem with SampleApp: it doesn't work without compiler optimizations.

    What compiler optimizations are you required to use?

     

  • Without optimizations

  • Perhaps I misunderstood what you meant.  Please let me try to clarify.

    Does it work with compiler optimizations?

    Does it work without compiler optimizations?

  • Did you turn off all optimization? Your code size will probably blow up then. But you should just really leave the optimization settings alone.
    If you need to turn off optimization on different modules (since it is for "best debug support") then you can override the inheited settings from
    the global setting in the project options. However, it is strongly advised not to turn off optimization globally from the project options.

  • With full optimizations it compiles, it links, I can upload the application to device, and it works

     

    Without optimitzations it compiles, it links, I can upload the application to device, but it doesn't works

     

    Please, try it!

  • It's a basic demostration. It doesn't work without optimizations???

     

    I understand that with a complex application you need to enable optimizations, but with a simple application???

  • BV(x)  is a function which moves 0x01 to left x bits. If you use P0_7, you must set BV(7). otherwise you can not set P0_7 pin correctly.