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.

How to make a program ?

Other Parts Discussed in Thread: CC2540

Hello,

i bought the MiniDK for my Thesis. I have already programmed my Atmega8 and now i have to transfer the program to the CC2540. My problem is that i don't know how to start.

I have already read the guides and debugged the SimpleBLEPeripherial.

What i know is that during the initialization OSAL has to register my app as a task. After the initialization OSAL is waiting for events which trigger the tasks.

What i need is a procedure how to change the SimpleBLEPheripherial so that my program works.

If you give me an example for the following program i will surely understand what to do further.

The program is very simple.

For the KeyFob:

The ADC has to be started every 4ms (256Hz).

The converted values (10bit or larger) have to be sent with an baudrate of 57000 to the dongle, that all should be done continously without requests.

The dongle is installed properly as a serial port, so that the data can be processed by a software.

Keyfob and dongle should know each other so that by pressing a key a link should be established and the data should be sent

Thats all.

Thx

Andi

  • I would not count on other people doing your job.

    You can start by observing the ADC example in the KeyFob project, which is using ADC to sense remaining battery.

    The baudrate 57000 is strange.

    You can do the behavior you want by working with autoconnect white lists in the dongle.

    Good luck :)

  • Hi kazola,

    it's not the whole program ! Only the frame of it.

    I don't know where to write my program.

    In the SimpleBLEPheripherial there ist the main task SimpleBLEPeripheral_ProcessEvent.

    It is triggered when it gets a message.

    The message comes from osal_run_system

    One part of the osal_run_system is:

    do {
        if (tasksEvents[idx])  // Task is highest priority that is ready.
        {
          break;
        }
      } while (++idx < tasksCnt);

    tasksEvents is defined as: uint16 *tasksEvents;

    and implemented in osalInitTasks: tasksEvents = (uint16 *)osal_mem_alloc( sizeof( uint16 ) * tasksCnt);

    So tasksEvents is an array ? How ?

    The while loop checks if any bit of the tasksEvents array is set. But where is it set ?

    Is there a function in IAR which finds all references of a variable, like in VS 2010 ?

  • Ok...

    to find all text referred to a variable in IAR try to press "Ctrl + Shift + F". Then you can travel along the project by clicking on each result row :)

    On the other hand, at the beginning of the program, for example in OSAL_HostTest.c or OSAL_SimplePeripheral.c, you'll see the place where the taskarray is built. and where each layer of the stack is assigned with a number = taskID. For example, AND THERE ARE NOT REAL NUMBERS, when doing:

      L2CAP_Init( taskID++ );

    taskID = 3, L2CAP layer will have a taskID = 3.

    In the code, you can send L2CAP-level events by osal_set_event(3).

    Please note this is a very basic example / notation.

    Bye!

  • I made a flowchart for SimpleBLEPeripheral maybe it will help somebody like me.

  • I need the ADC to convert with 256Hz. So i have to set  osal_timer_EX() to 3.9 but the function doesn't accept floats ? What can i do ?

    I want that the Keyfob and Dongle to connect automatically so that i can monitor and process the data with another program called Brainbay. With Brainbay i can't send any commands to the dongle thats why they should link by pressing on keyfobs button.

    Where can i find information about the whitelist ? Or a howto ? Didn't find anything about that.

  • asdfasdf asdfasd

    I share your pain. I am in  the same boat; I been reading TI's documents and code. but there is no design diagrams that can make understanding this thing much easier. Can you please upload your diagram into your files? I downloaded it but resolution is too low for it to be readable.

    thanks in advance

    LD.

  • Hi,

    Yes, it's really painful :=)

    It's not a real flowchart and not complete but i think it 's enough to understand the structure. You should go through the flowchart debugging the program.

    VISIO 2010:

    7774.SimpleBLEPeripherial.rar

    JPG:

    1464.SimpleBLEPeripheralJPG.rar

  • thanks for sharing.I bought also for the same for project.

    I have same problem also. I code read and document with difficult. Texas Instruments files are no good for me to understand. 

    Mr Kazola, how do you suggest we learn.

    Thank you for help

    Larry Yi

  • Mr. Drave

    You had helped more than TI members. 

    Thank you very much

    Larry Yi

  • You should start by opening the simplebleperipheral, and playing with simple things, for example, the leds, the advertising frames, the notifications... in this order :) There is no theoretical way to learn, but instead you have to test, fail, ask, test, test, test, fail, fail, search in the forum, search some more, test, fail and ask :)

    If you have not ever programmed, embedded programming is even a bit difficult ;) But sometimes you'll understand things when travelling, for example ;)

  • Mr Kazolo, thank you for you reply. I already doing but face difficult because i no find document for high level design to help understand code architecture and structure.  Thats why this post I made reply. I coding experience of 4 years but TI BLE code is difficult to understand. Mr Drave post help me more. You post very little help. thank you

    Larry Yi

  • Embedded programming is not high level programming. This is not Visual Basic and TI code is clear enough if you have enough pattience.

    I cannot further answer because I'm on my way to the church to punish myself for not being able to help you more.

  • Hey guys,

    bluegiga has the same uC built in an own evaluation kit. They developed a script language (bgscript)  which makes programming much more easier. You can use it on the TI evaluation kits  too. You can download it on bluegiga.com (BLE112: have to register).

  • You are extremely patient, especially with our questions that perhaps seem uninformed.  But I think I can sympathize with the other posters on this thread, because we don't necessarily know how the TI engine really works, and we don't necessarily know where to look.  We can see from the samples how to cause things to happen within the app in the CC2540, but not necessarily how to react to outside actions.  For example, I'd like to intercept the writing of a particular characteristic within a particular service, both identified by UUIDs, and then do my own processing.  I'm doing this in the context of the SimpleBLEPeripheral sample code, and I'm "hijacking" the device info service for now.  I think I can register a callback, or maybe change my planned logic a bit and just use the CB routine already registered (devInfo_ReadAttrCB), but I don't know what my responsibilities will be inside the callback.   For example, is it really a callback (invoked when the normal processing is complete) or is it a delegate (handles the complete set of processing)?  In the case of the read callback in SimpleBLEPeripheral it appears that the devInfo_ReadAttrCB routine is handling all of the processing.  So what would the responsibilities be for, let's say, a devInfo_WriteAttrCB routine?  When these callbacks are invoked how much time can I take in the routine? do I have as much as I want, or am I constrained?   And so on.

  • Yes, you are right. And i can't answer your questions :D

  • Actually, and no offense meant, I was replying to kazola, who has been a great help and shows lots of patience.

  • Hi, I've been outside for a few weeks and I've lost the meaning of the thread. Why we do not all verify this one and starts a new one with the remaining doubts?

    I think the thread title does no longer represents its content.

    Thanks!

  • By the time i made the program, its not that difficult as i thought. The only thing you need is time.

  • :)

    Nice to hear this. Verify the thread to keep the forum cleaner then. Bye!

  • I took the Heartrate example, i only had to change the heartrate.c:

    Interrupt Timer3: Starting ADC and sending Notification, but not at the same cycle.

    HAL_ISR_FUNCTION( Timer1ADCInterrupt, T3_VECTOR )
        {
              
              
           if(Timer1ADCIntFlag==0){
             ++NotifyHilf;
            Timer1ADCIntFlag=1;
          // 250Hz Abtastung und Filterung und Mittelwert Bildung
           adc_wert = HalAdcRead(HAL_ADC_CHANNEL_0,HAL_ADC_RESOLUTION_10);
           // bandpass_out=bandpass(adc_wert);
           // mittelwert_out=mittelwert_berechnen(abs(bandpass_out));
          }
          else{
            //heartRateMeasNotify();
    //              if(PortHilf==1)
    //                {P1=1;PortHilf=0;}
    //              else
    //                {P1=0;PortHilf=1;}
            Timer1ADCIntFlag=0;
          }
         if(NotifyHilf==100)
         {NotifyHilf=0;
         heartRateMeasNotify();
         }
          
        }

    Best friend is "Find in Files" CTRL+SHIFT+F

  • Hi Drave, 

                   I am new to bluegiga BLE112, i am struggling to configure this module. when i went through bluegiga website I got some info about ble112 but I am unable to configure this module and i did nnot understand about BGscript. 

    Can you please give explanation about BGscript and how to configure and programe BLE112 module please

    Thank you

    Regards

    Satya