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 / cc2531 developer help needed!

Other Parts Discussed in Thread: CC2531, Z-STACK, CC2530

Hi guys,

I'm currently learning how to use cc2531 / Z-Stack / IAR etc and could use some help setting up the sensor example app to work on 2531 as well as modifying it to do new things.

Please email me at  robstar (a t) gmail.com if you have a good working knowledge of programming the cc2530 and you're available to help for $$$

Thanks!

  • Hi Rob,

    What is the version of Z-stack you are playing with?

  • Hi, I'm using the latest one ... 

    The first thing I need help with is modifying the sensor example coord to work with the 2531 usb ... I want to see the data the sensors are sending appearing on my serial port for reading ..

    Thanks!

  • Hi,

    Start with the following thread.

    Basically, what should be done is replacing target in HAL->Target in the project

    from CC2530EB to CC2530USB (following this path:
    ...\Texas Instruments\ZStack-CC2530-2.5.0\Components\hal\target\CC2530USB.

    Then addind "additional include directories" in project options.

    Anyhow, first thing replace the HAL->Target section with CC2530USB, then try

    to compile (there will be errors, but I want you to post these errors so I could

    guide you step by step).

    Good luck

  • Thanks Igor.. this is what I did so far:

    1) loaded SimpleApp and chose SimpleCollectorEB

    2) Project->General Options -> Target -> Device changed to  CC2531F256

    3) Project -> C/C++ Compiler -> Preprocessor changed:

    $PROJ_DIR$\..\..\..\..\..\Components\hal\include

    $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530USB
    $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530USB\usb\library
    $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530USB\usb\library\cc2531
    $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530USB\usb\class_cdc

    With these changes it compiles perfectly .. but not sure if it picked up the correct 2531 HAL changes.. is there anything else I need to do?

    Thanks!

  • To add the OSC32K_CRYSTAL_INSTALLED=FALSE compilation flag

    in  C/C++ Compiler -> Preprocessor-> defined symbols (as the 32KHz crystal

    is absent on cc2531 USB dongle).

    In General Options -> target select the CC2531F256 instead of CC2530F256.

    Compile and download this FW into cc2531 USB dongle. then plug it to PC,

    at this point WinOS should recognize this device as CDC

  • Ok, it compiles fine.. but when I download and debug it dumps crazy amounts of verification errors..

    also, debugging doesn't work - you can't step .. only option is break or stop debugging..

    any ideas?

    Wed Nov 21 16:54:40 2012: Warning: Verification error on page #0, address range 0x00000 - 0x00800, address 0x00000, 0x00 (on target) != 0x02 (in object file).
    Wed Nov 21 16:54:40 2012: Warning: Verification error on page #0, address range 0x00000 - 0x00800, address 0x00001, 0x00 (on target) != 0x0A (in object file).
    Wed Nov 21 16:54:40 2012: Warning: Verification error on page #0, address range 0x00000 - 0x00800, address 0x00002, 0x00 (on target) != 0xA1 (in object file).
    Wed Nov 21 16:54:40 2012: Warning: Verification error on page #0, address range 0x00000 - 0x00800, address 0x00003, 0x00 (on target) != 0x02 (in object file).
    Wed Nov 21 16:54:40 2012: Warning: Verification error on page #0, address range 0x00000 - 0x00800, address 0x00004, 0x00 (on target) != 0x01 (in object file).
    Wed Nov 21 16:54:40 2012: Warning: Verification error on page #0, address range 0x00000 - 0x00800, address 0x00005, 0x00 (on target) != 0xD4 (in object file).
    Wed Nov 21 16:54:40 2012: Warning: Verification error on page #0, address range 0x00000 - 0x00800, address 0x00006, 0x00 (on target) != 0xFF (in object file).
    Wed Nov 21 16:54:40 2012: Warning: Verification error on page #0, address range 0x00000 - 0x00800, address 0x00007, 0x00 (on target) != 0xFF (in object file).
    Wed Nov 21 16:54:40 2012: Warning: Verification error on page #0, address range 0x00000 - 0x00800, address 0x00008, 0x00 (on target) != 0xFF (in object file).
    Wed Nov 21 16:54:40 2012: Warning: Verification error on page #0, address range 0x00000 - 0x00800, address 0x00009, 0x00 (on target) != 0xFF (in object file).
    Wed Nov 21 16:54:40 2012: Warning: Verification error on page #0, address range 0x00000 - 0x00800, address 0x0000A, 0x00 (on target) != 0xFF (in object file).

    .................

    .................

    Wed Nov 21 16:54:42 2012: Warning: Verification error on page #32, address range 0x3F800 - 0x00800, address 0x3FFF9, 0x00 (on target) != 0xFF (in object file).
    Wed Nov 21 16:54:42 2012: Warning: Verification error on page #32, address range 0x3F800 - 0x00800, address 0x3FFFA, 0x21 (on target) != 0xFF (in object file).
    Wed Nov 21 16:54:42 2012: Warning: Verification error on page #32, address range 0x3F800 - 0x00800, address 0x3FFFB, 0x3D (on target) != 0xFF (in object file).
    Wed Nov 21 16:54:42 2012: Warning: Verification error on page #32, address range 0x3F800 - 0x00800, address 0x3FFFC, 0x00 (on target) != 0xFF (in object file).
    Wed Nov 21 16:54:42 2012: Warning: Verification error on page #32, address range 0x3F800 - 0x00800, address 0x3FFFD, 0x00 (on target) != 0xFF (in object file).
    Wed Nov 21 16:54:42 2012: Warning: Verification error on page #32, address range 0x3F800 - 0x00800, address 0x3FFFE, 0x00 (on target) != 0xFF (in object file).
    Wed Nov 21 16:54:42 2012: Warning: Verification error on page #32, address range 0x3F800 - 0x00800, address 0x3FFFF, 0x00 (on target) != 0xFF (in object file).
    Wed Nov 21 16:54:42 2012: Download completed and verification successful.
    Wed Nov 21 16:54:46 2012: Warning: There were warnings during download, see Debug Log window for more information
    Wed Nov 21 16:54:46 2012: Loaded debugee: C:\Texas Instruments\ZStack-CC2530-2.5.1a\Projects\zstack\Samples\SimpleApp\CC2530DB\SimpleCollectorEB\Exe\SimpleApp.d51
    Wed Nov 21 16:54:46 2012: Target reset
    Wed Nov 21 16:54:46 2012: There was 1 warning during the initialization of the debugging session.

  • also, when I plug it in now ... the usb comm port is no longer detected.. I don't think the 2531 HAL is active?

  • Seems like a shaky connection between CC Debugger/ SmartRF05EB and the dongle.

    These are the steps to be followed when programming the dongle:

    • Plug the CC2531 Dongle into a USB (working PC)
    • Connect the CC2531 Dongle to CC Debugger/ smartRF05EB through debug connector
      with a flat ribbon cable (pay attention on the direction of the flat cable).
    • Either connect CC debugger to USB (at this point the LED should turn green),
      or connect smartRF05EB to USB, something will be displayed on the LCD, when
      the bottom line will state CC2531.
    • Run smartRF flash programmer, ensure the CC2531 is detected by the program,
      select "erase" and perform the action. (this step should be done only once, to 
      erase all the leftovers from previous FW downloads) 
    • In the IAR press the Ctrl+D.
  • Wow you're right .. I reconnected it and it downloaded fine.... but like all the times I've tried this before, usb is not detected

    I plug it into the USB and no device is recognized...  I don't think the 2531 stuff is working ...  

    I have a working project that was ported to 2531 for real I grabbed from here called GenericApp and the directory structure is quite different .  That one works perfectly ...

    there must be something else that needs to be linked to make the HAL get picked up by the project..  how can I switch the target for real in this project.. as you can see, it's still pointing to CC2530EB

  • I thought you've replaced the CC2530EB (under target) with CC2530USB, as I mentioned in of my previous posts

    (second one if I'm not mistaken) in this thread.

  • I'm off to have some sleep, so we'll keep with this tomorrow (actually in eight hours from now).

    Good luck

  • OK, I got it compiled and running - Thanks! !  A few questions about the SimpleApp:

    1) when I plug in the 2531 usb .. should the program start transmitting some sort of zigbee beacon signal I can sniff? I don't sniff any packets.

      SERIAL App sent a beacon every second so I could confirm that something was working when watching the sniffer

    2) is it possible to modify the program to automatically discover and pair with devices on the same PAN on bootup?  (I don't have any buttons on my module) ...    where is the best code place to automatically put the coord into device discovery and the sensors into finding the coord and starting to transmit?

    Thanks!

  • Rob Platek said:

    1) when I plug in the 2531 usb .. should the program start transmitting some sort of zigbee beacon signal I can sniff? I don't sniff any packets.

      SERIAL App sent a beacon every second so I could confirm that something was working when watching the sniffer

    I'm not familiar with the program flow of simpleApp, refer to "Z-Stack Sample Applications.pdf" for more info.

    (My guest, it simply waits for some trigger to start the normal operation of the device)

    Rob Platek said:
    2) is it possible to modify the program to automatically discover and pair with devices on the same PAN on bootup?  (I don't have any buttons on my module) ...    where is the best code place to automatically put the coord into device discovery and the sensors into finding the coord and starting to transmit?

    How come you have no buttons on your module, isn't it the CC2531 USB dongle by TI?

    And yes, you can make some changes in the code to meet your needs. 

  • ok great ... I'm trying to wrap my head around alot of things (Z-Stack, IAR, etc) ..

    I have a dongle device, but I also have a couple of bare bones units with no buttons or leds ..  it looks like this whole platform is event driven .. where is the best place in the code to fire up the zigbee engine automatically?

    is there a standard function (main()?) where I can simulate a key press or call the functions to start the module pairing?

    Thanks!

  • Did you figure it out or not? Somehow I missed your post.

  • Hi Igor,

    I've had some progress!  I've spent the whole afternoon on the dumbest thing ever:

      char a[8] = "sdfsdfs\0";
      
      // get total length of packet data
      data_str_len = osal_strlen(a);

    data_str_len = 654 or some random garbage value ... this makes no sense?!?
    how can osal_strlen() be broken?
  • Hi,

    What happens if you assign a[7] with zero?

    Like this:

    char a[8] = "sdfsdfs\0";
      
      a[7] = 0;
      // get total length of packet data
      data_str_len = osal_strlen(a);


    By the way, until today I wasn't aware osal_strlen, it's not documented in any of the OSAL API.pdf
    May be there is a reason to that?
    Anyhow, osal_strlen() is a wrapper of C-library strlen()
  • No difference.. this is pretty crazy, something so simple!

    How do you check a string length in Z-stack??

    int data_str_len;
    char a[8] = "sdfsdfs\0";

    a[7] = 0;

    // get total length of packet data
    data_str_len = osal_strlen(a);

    data_str_len = 493

  • One of two thing, am really tired right now and missing the obvious, or something wrong 

    with the definition and initialization of the a[] array.

    1. Place a breakpoint on a[7] = 0; expression.
    2. When the debugging session halts on this line, add "a" to the watch window, and expand it
    3. what is the value of a[7]?
    4. If this value is 0, then remove breakpoint from a[7] = 0; and place a breakpoint on data_str_len = osal_strlen(a);
      let the debugging session run until it halts on the breakpoint.
    5. Once it triggered, you'll notice the breakpoint on the disassembly window, try to debug this in assembly.
      My guess something related to djnz with Rx 
  • OK thanks I'll try it .. 2 questions:

    1) is it possible to dump info to the IAR debug log?

    2) when the debugger stops on a break point that's all I get ... it will never step to the next instruction, IAR blinks red and you can't continue.  have you seen this before?

  • Rob Platek said:
    1) is it possible to dump info to the IAR debug log?

    Enable the check box highlighted on the image:


    Rob Platek said:
    2) when the debugger stops on a break point that's all I get ... it will never step to the next instruction, IAR blinks red and you can't continue.  have you seen this before?

    Again, could you please attach the source file, I'll try to reproduce this issue on my PC?

  • Awesome, I'll try that.

    I tried what you said with the debugging.. I've attached a picture.  this problem is kind of scaring me .. can you tell anything from the screen capture?

    thanks!

  • Regarding communication log, I'm not sure if it records the breakpoint triggers, etc..

    I have not tried it my self, so please update me on the result.

    Regarding the image, well, I cannot see the disassemby, I can only see the machine code part of the window.

    You can scroll it left or better expand it.

    Meanwhile you shouldn't be scared, the code optimization can do some crazy things.

    You can try to run your code without the optimizations.

  • Turning OFF optimization actually fixed it .. does this mean with it on high the code wasn't running properly?

    should I leave it off from now on?  or do I turn it back on when the code is done?

    thanks for your help!

  • It is something unusual.

    Optimization of the code must not affect the original execution (original functionality).

    If you have no need in optimization, meaning reduced size of code, you can leave the

    optimization off, otherwise it should be turned on.

    You know, it's not the first time when an optimization actually screws up the execution

    of a code. In your case it is quite a simple code, so maybe there are deeper faults in your

    case. Some memory being overlapped and rewritten by another access.

    If you have the time and you willing know the truth you should investigate it further.

  • Hi Igor,

    That also scares me.. I just started this application and I hope there isn't demons hiding inside like I'm seeing.  I've attached the source code, which is basically SimpleApp, but I added serial port initialization SerialApp_Init() called from osalInitTasks()

    and a serial callback function .. is there any chance I screwed something up in SerialApp_Init or maybe used the wrong task_id or something?  I'd be interested to see if you can reproduce the wrong data_str_len on line 483

    code: https://dl.dropbox.com/u/3818984/broken-code.rar

    I'm hoping something will stand out as wrong that could be causing this very strange problem!  Thanks!!

    To reproduce: run the debugged, open hyperterminal and press a few keys on the usb comm port (cc2531) .. the app should call the callback 

  • Hi Igor,

    i have halted development until I hear from you..do you think it's safe to continue development with this strange problem occurring ?

  • Hi Igor,

    I did a test... 

    data_str_len = osal_strlen(a);

    if(data_str_len == 7) {
    asm("nop");
    }

    and ran it with code optimization OFF and HIGH ... both entered the if stmt .. which means even though the debugger was reporting crazy values .. it was actually == 7

    Guess that's settled.. thanks for your help (for now haha)

  • Good.

    Now that I'm thinking about it, the compiler probably assigned some arbitrary

    value to the data_str_len after data_str_len = osal_strlen(a); since it never used after

    this expression, however adding a if() condition changed the behavior. :)