"Bluetooth Data Acquisition module" -00-sensor Controller function Introduction

Source: Internet
Author: User

One

The internal block diagram of the CC2650 chip contains:

A CORTEX-M3 master controller that is used to perform the functions and tasks of the entire chip.

A CORTEX-M0 RF controller to drive RF-related circuitry

A sensor controller that can be used to capture the data of sensors when the host controller sleeps, to reduce the overall power consumption of the system.

As we can see from the diagram, the modules that the Sensor controller can directly control include:

1. Analog acquisition, 2. Comparator, 3.SPI and I²c interface, 4. Constant current source, 5. Timer, 6.2KB SRAM

Furthermore, the Sensor controller has access to some of the peripherals of the main controller:

1.UART Serial, 2.GPIO,

In general, the CC2650RGZ chip used in the CC2650STK can control 16 pins in the entire chip through the sensor controller, 8 of which can be used as analog acquisition.

Two

Although the sensor controller looks great, there is still some trouble in developing it.

1. Need to use the dedicated development software sensor Controller Studio to develop the program;

2. After the function debugging, it is necessary to add the driver interface of the software to the CCS project of CC2650;

3. It is necessary to coordinate how the two interact with the data so that the host controller can poll or the sensor controller to trigger the interrupt.

Anyway, let's take a look at the software of Sensor Controller Studio. The interface of the software is as follows.

Turn the Start page on the right into the navigation window, which includes four items,

1. Project: Set up new projects, open existing projects, the most recent engineering catalogue

2. Routine: Mainly includes smartrf06eb and I used Sensortag Two Board example

3. Documentation of the Tools directory 4. Online documentation and resources

Because there are ready-made examples, we directly open the example of Sensortag's i²c light sensor to introduce the use of this software.

Double-clicking the I²c light sensor will pop up the following window

All the back with ... The buttons are all options that can be modified.

The first one is to select a directory to save the project,

And then there's a ti-rtos releas option, because I'm going to use 2.13 in CCS, and that's 2.13,

Corresponding, the following in the overrides have a lot of options, all choose Tirtos_simplelink_2_13_00_06 version and Xdctools_3_31_01_33_core, as for the election will not affect the final program call, I do not know, For the first time, don't mess it up.

Click OK to jump directly to the configuration directory of this project. All of them remain by default.

At the bottom is a column called the Sensor Controller tasks, which can be used to create new tasks in the project. After all, this is a coprocessor with the operating system, is the high-end, but also to configure tasks.

On the left, click the directory next to the "-" (This is the first task of our project) and you can see the following interface. In this interface, you can configure the module used by the project, which needs to be checked. Some of the modules can also be configured for parameters, this need to slowly pondering the study. When a module is selected, the corresponding macro definition of the module, the driver interface, is automatically added to the project.

Looking down in the left window, you can see that this task contains four parts of the code, the software is directly defined. There are initialization code, execution code, event handling code, and end code. Hence the name is what they want to do. This is not a detailed talk.

Look directly at execution code and Event Handler codes.

Execution Code:

1 //Configure and start the next measurement2 I2cstart ();3I2ctx (I2c_op_write |als_i2c_addr);4 I2ctx (als_reg_cfg);5I2ctx (Als_cfg_one_shot >>8);6I2ctx (Als_cfg_one_shot >>0);7 i2cstop ();8 9 //Read The result after milliseconds + a 20% marginTenEvhsetuptimertrigger (0, -,2); One  A //Schedule the next execution -Fwscheduletask (1);

Event Handler Code:

//If A measurement is successfully started during the last execution ...if(State.i2cstatus = =0x0000) {        //Select The result registerI2cstart (); I2ctx (I2c_op_write|als_i2c_addr);        I2ctx (Als_reg_result); //If Successful ...    if(State.i2cstatus = =0x0000) {U16 Resultregh;                U16 Resultregl; //Read The resultI2crepeatedstart (); I2ctx (I2c_op_read|als_i2c_addr);        I2crxack (Resultregh);        I2crxnack (RESULTREGL);                I2cstop (); //Convert The result (4-bit exponent + 12-bit mantissa) into 16-bit fixed-pointU16 exp = Resultregh >>4; U16 mant= (Resultregh << A) | (Resultregl <<4); //The exponent is in range 0 to oneU16 value = Mant >> ( One-exp); Output.value=value; //Notify the application with the result was below the low threshold or above the high threshold        if(Value <cfg.lowthreshold) {fwgenalertinterrupt (); }        if(Value >cfg.highthreshold) {fwgenalertinterrupt (); }            } Else{i2cstop (); }}

It is not complicated to ponder it. The main function is to read the Sensortag above the light sensor data, and the upper and lower threshold comparison, out of range will trigger an interrupt signal to the main controller (this is discussed later).

In this code, such as the driver function of the i²c, the task, the event handler function, the interrupt trigger function are automatically added after the selection function module mentioned above. Calls are made directly in the program without the use of declarations, inclusions, and the like.

Further down to the I/O Mapping, the function pin can be configured. In this project we only use the I²c module, so directly configure SDA and SCL two pin can be. The I/O pin configuration can be completed by clicking on the corresponding Pin box on the mouse.

The following is code Generator, which is used to compile it. It actually puts the machine code into an array in the C file, and in the main controller program, it compiles that part of the code into a specific address space to implement the sensor controller's program. (Not very clear, if there is a mistake, then to modify this place)

Click on the Generate driver source code on the right, and you will be able to encapsulate the code of the project without errors and generate the relevant drivers in CCS. In the middle we can also see the use of resources in this project situation.

Finally, the simulation is first off, Task testing.

In addition to the debug process in (simplified workflow), there is one (low-level workflow), such as. Choose according to the actual needs.

Finally, we connect the board and press the Run button to see the light intensity signal collected by the sensor controller and be able to display it with curves.

In this way, we have already understood the basic functions of the sensor controller. Some specific functions need to be realized in actual use. Now I know of some cases, its Class C language syntax is not complete, variable class only 16-bit signed, 16-bit unsigned, 1-bit bit type, multiple tasks cannot call the same peripheral module.

Later, my expectation was to read and write all the sensor modules in the sensors controller and to encapsulate the drivers. I wonder if the space will be full enough.

"Bluetooth Data Acquisition module" -00-sensor Controller function Introduction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.