Bluetooth clock calculation circuit, Bluetooth clock calculation method, medium, and device

文档序号:808237 发布日期:2021-03-26 浏览:26次 中文

阅读说明:本技术 蓝牙时钟计算电路、蓝牙时钟计算方法、介质及设备 (Bluetooth clock calculation circuit, Bluetooth clock calculation method, medium, and device ) 是由 陈金宏 彭国杰 李蕙 于 2020-12-16 设计创作,主要内容包括:本公开涉及一种蓝牙时钟计算电路、蓝牙时钟计算方法、介质及设备,能够在任意时刻简单、快速地得到任意经典蓝牙链路的当前蓝牙时钟。包括:启动模块,用于在接收到蓝牙时钟计算指令时,启动所述蓝牙时钟计算电路;采集模块,用于采集本地蓝牙时钟的第一时钟值和第一微秒计数器的第一计数值;第一计算模块,用于确定在目标蓝牙时钟的第二微秒计数器处于0时所述第一微秒计数器对应的第二计数值;第二计算模块,用于根据所述第一计数值,确定所述目标蓝牙时钟的目标计数值;第三计算模块,用于根据所述第一时钟值、所述第二计数值、所述目标计数值,确定所述目标蓝牙时钟的目标时钟值;输出模块,用于输出所述目标计数值和所述目标时钟值。(The present disclosure relates to a bluetooth clock calculation circuit, a bluetooth clock calculation method, medium, and device, which can simply and quickly obtain a current bluetooth clock of any classic bluetooth link at any time. The method comprises the following steps: the starting module is used for starting the Bluetooth clock calculation circuit when receiving a Bluetooth clock calculation instruction; the acquisition module is used for acquiring a first clock value of a local Bluetooth clock and a first count value of a first microsecond counter; the first calculating module is used for determining a second counting value corresponding to a first microsecond counter when the second microsecond counter of a target Bluetooth clock is 0; the second calculation module is used for determining a target count value of the target Bluetooth clock according to the first count value; the third calculating module is used for determining a target clock value of the target Bluetooth clock according to the first clock value, the second counting value and the target counting value; and the output module is used for outputting the target count value and the target clock value.)

1. A bluetooth clock calculation circuit, comprising:

the starting module is used for starting the Bluetooth clock calculation circuit when receiving a Bluetooth clock calculation instruction;

the acquisition module is used for acquiring a first clock value of a local Bluetooth clock and a first count value of a first microsecond counter of the local Bluetooth clock under the condition that the Bluetooth clock calculation circuit is started;

the first calculating module is used for determining a second counting value corresponding to a first microsecond counter when the second microsecond counter of a target Bluetooth clock is 0;

the second calculation module is used for determining a target count value of the target Bluetooth clock according to the first count value;

the third calculating module is used for determining a target clock value of the target Bluetooth clock according to the first clock value, the second counting value and the target counting value;

and the output module is used for outputting the target count value and the target clock value to a sender of the Bluetooth clock calculation instruction.

2. The bluetooth clock calculation circuit according to claim 1, wherein the bluetooth clock calculation instruction carries first time difference information, the first time difference information is used to indicate a time difference between when the second microsecond counter is at 0 microseconds and when the first microsecond counter is at a preset microsecond value, and the preset microsecond value is a value corresponding to a middle point of a counting range of the first microsecond counter;

the first computing module includes:

the first subtractor is used for calculating a first difference value obtained by subtracting the time difference indicated by the first time difference information from a first preset value;

and the first carry processing submodule is used for performing a remainder operation by using the first difference value and a second preset value to obtain the second count value.

3. The bluetooth clock calculation circuit according to claim 1, wherein the bluetooth clock calculation instruction carries first time difference information, the first time difference information is used to indicate a time difference between when the second microsecond counter is at 0 microseconds and when the first microsecond counter is at a preset microsecond value, and the preset microsecond value is a value corresponding to a middle point of a counting range of the first microsecond counter;

the second calculation module includes:

a first adder, configured to calculate a first sum of a third preset value, the time difference indicated by the first time difference information, and the first count value;

and the second carry processing submodule is used for carrying out a remainder operation by utilizing the first sum value and a fourth preset value to obtain the target count value.

4. The bluetooth clock calculation circuit according to claim 1, wherein a clock value of the bluetooth clock is represented by a preset number of bits, and the lowest N bits of the preset number of bits are low bits, and the other bits except the low bits of the preset number of bits are high bits, where N is a positive integer;

the third computing module comprises:

a low bit clock value calculation operator module for determining a first value of low bits corresponding to the target bluetooth clock according to the target count value;

a high bit clock value calculation operator module, configured to determine a second value corresponding to a high bit of the target bluetooth clock according to the first clock value and the second count value;

and the target clock value determining submodule is used for determining the target clock value according to the first value and the second value.

5. The bluetooth clock calculation circuit of claim 4, wherein the lower bit clock value operator module comprises:

the range judger is used for judging a numerical value interval in which the target counting value is positioned according to a plurality of preset numerical value intervals as a target numerical value interval;

and the first determining submodule is used for determining the bit value corresponding to the target value interval as the first value according to the preset corresponding relation between a plurality of value intervals and a plurality of kinds of bit values.

6. The bluetooth clock calculation circuit according to claim 4, wherein the bluetooth clock calculation instruction carries second time difference information, the second time difference information is used to indicate a time difference between a clock value corresponding to the target bluetooth clock and a clock value of a local bluetooth clock at a time when the second microsecond counter is at 0 microsecond;

the high bit clock value operator module comprises:

the comparator is used for comparing the first count value with the second count value and obtaining an output value according to a comparison result, wherein if the first count value is greater than or equal to the second count value, the output value is 0, and if the first count value is smaller than the second count value, the output value is 1;

a second subtractor for calculating a difference between a bit value corresponding to a higher bit in the first count value and the output value as a second difference;

a second adder configured to calculate a second sum value of the second difference value and a bit value of a higher bit corresponding to the time difference indicated by the second time difference information, and to take the second sum value as the second value.

7. The bluetooth clock calculation circuit of claim 1, wherein the bluetooth clock calculation circuit further comprises:

and the closing module is used for closing the Bluetooth clock calculation circuit after the sender of the Bluetooth clock calculation instruction reads the target count value and the target clock value from the output module.

8. A Bluetooth clock calculation method is applied to a Bluetooth clock calculation circuit, the Bluetooth clock calculation circuit comprises a starting module, an acquisition module, a first calculation module, a second calculation module, a third calculation module and an output module, and the method comprises the following steps:

when a Bluetooth clock calculation instruction is received, acquiring a first clock value of a local Bluetooth clock and a first count value of a first microsecond counter of the local Bluetooth clock;

determining a second count value corresponding to the first microsecond counter when a second microsecond counter of a target Bluetooth clock is at 0;

determining a target count value of the target Bluetooth clock according to the first count value;

determining a target clock value of the target Bluetooth clock according to the first clock value, the second count value and the target count value;

and outputting the target counting value and the target clock value to a sender of the Bluetooth clock calculation instruction.

9. The method according to claim 8, wherein the bluetooth clock calculation instruction carries first time difference information, the first time difference information being used to represent a time difference between when the second microsecond counter is at 0 microseconds and when the first microsecond counter is at a preset microsecond value, the preset microsecond value being a value corresponding to a midpoint of a counting range of the first microsecond counter;

the determining a second count value corresponding to the first microsecond counter when a second microsecond counter of the target bluetooth clock is at 0 includes:

and calculating a first difference value obtained by subtracting the time difference indicated by the first time difference information from a first preset value, and performing a remainder operation by using the first difference value and a second preset value to obtain a second counting value.

10. The method according to claim 8, wherein the bluetooth clock calculation instruction carries first time difference information, the first time difference information being used to represent a time difference between when the second microsecond counter is at 0 microseconds and when the first microsecond counter is at a preset microsecond value, the preset microsecond value being a value corresponding to a midpoint of a counting range of the first microsecond counter;

the determining the target count value of the target bluetooth clock according to the first count value includes:

and calculating a first sum of a third preset numerical value, the time difference indicated by the first time difference information and the first counting value, and performing remainder operation by using the first sum and a fourth preset numerical value to obtain the target counting value.

11. The method according to claim 8, wherein the clock value of the bluetooth clock is represented by a preset number of bits, and the lowest N bits of the preset number of bits are low bits, and the other bits of the preset number of bits except the low bits are high bits, where N is a positive integer;

the determining a target clock value of the target bluetooth clock according to the first clock value, the second count value, and the target count value includes:

determining a first value corresponding to low bits of the target Bluetooth clock based on the target count value;

determining a second value corresponding to a high bit of the target Bluetooth clock according to the first clock value and the second count value;

determining the target clock value according to the first value and the second value.

12. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 8 to 11.

13. An electronic device comprising the bluetooth clock calculation circuit of any one of claims 1-7.

Technical Field

The present disclosure relates to the field of bluetooth, and in particular, to a bluetooth clock calculation circuit, a bluetooth clock calculation method, a bluetooth clock calculation medium, and a bluetooth clock calculation device.

Background

Currently, to obtain a bluetooth clock, two ways of hardware reading and software calculation are generally used. In the hardware reading mode, the bluetooth clock is obtained by reading the hardware register, however, the bluetooth link required to be accessed in the hardware reading mode needs to be the same link as the current baseband hardware, so that the hardware reading mode has a great limitation. In the software calculation mode, although the acquisition of the bluetooth clock can be realized, the problem of value jump needs to be considered because the local bluetooth clock and the local microsecond counter cannot be read simultaneously by software and the reading sequence exists, and the calculation processing process is complex and consumes long time.

Disclosure of Invention

An object of the present disclosure is to provide a bluetooth clock calculation circuit, a bluetooth clock calculation method, medium, and device, which facilitate acquisition of a bluetooth clock of an arbitrary bluetooth link.

To achieve the above object, according to a first aspect of the present disclosure, there is provided a bluetooth clock calculation circuit including:

the starting module is used for starting the Bluetooth clock calculation circuit when receiving a Bluetooth clock calculation instruction;

the acquisition module is used for acquiring a first clock value of a local Bluetooth clock and a first count value of a first microsecond counter of the local Bluetooth clock under the condition that the Bluetooth clock calculation circuit is started;

the first calculating module is used for determining a second counting value corresponding to a first microsecond counter when the second microsecond counter of a target Bluetooth clock is 0;

the second calculation module is used for determining a target count value of the target Bluetooth clock according to the first count value;

the third calculating module is used for determining a target clock value of the target Bluetooth clock according to the first clock value, the second counting value and the target counting value;

and the output module is used for outputting the target count value and the target clock value to a sender of the Bluetooth clock calculation instruction.

Optionally, the bluetooth clock calculation instruction carries first time difference information, where the first time difference information is used to indicate a time difference between when the second microsecond counter is at 0 microsecond and when the first microsecond counter is at a preset microsecond value, and the preset microsecond value is a value corresponding to a midpoint of a counting range of the first microsecond counter;

the first computing module includes:

the first subtractor is used for calculating a first difference value obtained by subtracting the time difference indicated by the first time difference information from a first preset value;

and the first carry processing submodule is used for performing a remainder operation by using the first difference value and a second preset value to obtain the second count value.

Optionally, the bluetooth clock calculation instruction carries first time difference information, where the first time difference information is used to indicate a time difference between when the second microsecond counter is at 0 microsecond and when the first microsecond counter is at a preset microsecond value, and the preset microsecond value is a value corresponding to a midpoint of a counting range of the first microsecond counter;

the second calculation module includes:

a first adder, configured to calculate a first sum of a third preset value, the time difference indicated by the first time difference information, and the first count value;

and the second carry processing submodule is used for carrying out a remainder operation by utilizing the first sum value and a fourth preset value to obtain the target count value.

Optionally, the clock value of the bluetooth clock is represented by a preset number of bits, and the lowest N bits of the preset number of bits are low bits, and the other bits except the low bits of the preset number of bits are high bits, where N is a positive integer;

the third computing module comprises:

a low bit clock value calculation operator module for determining a first value of low bits corresponding to the target bluetooth clock according to the target count value;

a high bit clock value calculation operator module, configured to determine a second value corresponding to a high bit of the target bluetooth clock according to the first clock value and the second count value;

and the target clock value determining submodule is used for determining the target clock value according to the first value and the second value.

Optionally, the low-bit clock value operator module includes:

the range judger is used for judging a numerical value interval in which the target counting value is positioned according to a plurality of preset numerical value intervals as a target numerical value interval;

and the first determining submodule is used for determining the bit value corresponding to the target value interval as the first value according to the preset corresponding relation between a plurality of value intervals and a plurality of kinds of bit values.

Optionally, the bluetooth clock calculation instruction carries second time difference information, where the second time difference information is used to indicate a time difference between a clock value corresponding to the target bluetooth clock and a clock value of the local bluetooth clock at a time when the second microsecond counter is at 0 microsecond;

the high bit clock value operator module comprises:

the comparator is used for comparing the first count value with the second count value and obtaining an output value according to a comparison result, wherein if the first count value is greater than or equal to the second count value, the output value is 0, and if the first count value is smaller than the second count value, the output value is 1;

a second subtractor for calculating a difference between a bit value corresponding to a higher bit in the first count value and the output value as a second difference;

a second adder configured to calculate a second sum value of the second difference value and a bit value of a higher bit corresponding to the time difference indicated by the second time difference information, and to take the second sum value as the second value.

Optionally, the bluetooth clock calculation circuit further includes:

and the closing module is used for closing the Bluetooth clock calculation circuit after the sender of the Bluetooth clock calculation instruction reads the target count value and the target clock value from the output module.

According to a second aspect of the present disclosure, there is provided a bluetooth clock calculation method applied to a bluetooth clock calculation circuit, where the bluetooth clock calculation circuit includes a start module, an acquisition module, a first calculation module, a second calculation module, a third calculation module, and an output module, the method includes:

when a Bluetooth clock calculation instruction is received, acquiring a first clock value of a local Bluetooth clock and a first count value of a first microsecond counter of the local Bluetooth clock;

determining a second count value corresponding to the first microsecond counter when a second microsecond counter of a target Bluetooth clock is at 0;

determining a target count value of the target Bluetooth clock according to the first count value;

determining a target clock value of the target Bluetooth clock according to the first clock value, the second count value and the target count value;

and outputting the target counting value and the target clock value to a sender of the Bluetooth clock calculation instruction.

Optionally, the bluetooth clock calculation instruction carries first time difference information, where the first time difference information is used to indicate a time difference between when the second microsecond counter is at 0 microsecond and when the first microsecond counter is at a preset microsecond value, and the preset microsecond value is a value corresponding to a midpoint of a counting range of the first microsecond counter;

the determining a second count value corresponding to the first microsecond counter when a second microsecond counter of the target bluetooth clock is at 0 includes:

and calculating a first difference value obtained by subtracting the time difference indicated by the first time difference information from a first preset value, and performing a remainder operation by using the first difference value and a second preset value to obtain a second counting value.

Optionally, the bluetooth clock calculation instruction carries first time difference information, where the first time difference information is used to indicate a time difference between when the second microsecond counter is at 0 microsecond and when the first microsecond counter is at a preset microsecond value, and the preset microsecond value is a value corresponding to a midpoint of a counting range of the first microsecond counter;

the determining the target count value of the target bluetooth clock according to the first count value includes:

and calculating a first sum of a third preset numerical value, the time difference indicated by the first time difference information and the first counting value, and performing remainder operation by using the first sum and a fourth preset numerical value to obtain the target counting value.

Optionally, the clock value of the bluetooth clock is represented by a preset number of bits, and the lowest N bits of the preset number of bits are low bits, and the other bits except the low bits of the preset number of bits are high bits, where N is a positive integer;

the determining a target clock value of the target bluetooth clock according to the first clock value, the second count value, and the target count value includes:

determining a first value corresponding to low bits of the target Bluetooth clock based on the target count value;

determining a second value corresponding to a high bit of the target Bluetooth clock according to the first clock value and the second count value;

determining the target clock value according to the first value and the second value.

According to a third aspect of the present disclosure, there is provided a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the method of the second aspect of the present disclosure.

According to a fourth aspect of the present disclosure, there is provided an electronic device comprising the bluetooth clock calculation circuit according to the first aspect of the present disclosure.

Through the technical scheme, the Bluetooth clock calculation circuit comprises a starting module, an acquisition module, a first calculation module, a second calculation module, a third calculation module and an output module. The starting module is used for starting the Bluetooth clock calculation circuit when receiving a Bluetooth clock calculation instruction; the acquisition module is used for acquiring a first clock value of a local Bluetooth clock and a first count value of a first microsecond counter of the local Bluetooth clock under the condition that the Bluetooth clock calculation circuit is started; the first calculating module is used for determining a second counting value corresponding to the first microsecond counter when the second microsecond counter of the target Bluetooth clock is 0; the second calculation module is used for determining a target count value of the target Bluetooth clock according to the first count value; the third calculating module is used for determining a target clock value of the target Bluetooth clock according to the first clock value, the second counting value and the target counting value; the output module is used for outputting the target count value and the target clock value to a sender of the Bluetooth clock calculation instruction. Therefore, the Bluetooth clock calculation circuit realized by hardware can acquire the current Bluetooth clock of any Bluetooth link at any time, and the calculation is simple and rapid.

Additional features and advantages of the disclosure will be set forth in the detailed description which follows.

Drawings

The accompanying drawings, which are included to provide a further understanding of the disclosure and are incorporated in and constitute a part of this specification, illustrate embodiments of the disclosure and together with the description serve to explain the disclosure without limiting the disclosure. In the drawings:

fig. 1 is a schematic structural diagram of a bluetooth clock calculation circuit provided according to an embodiment of the present disclosure;

FIG. 2 is a schematic block diagram of a first computing module provided in accordance with one embodiment of the present disclosure;

FIG. 3 is a schematic block diagram of a second computing module provided in accordance with one embodiment of the present disclosure;

FIG. 4 is a schematic block diagram of a third computing module provided in accordance with one embodiment of the present disclosure;

FIG. 5 is a schematic structural diagram of a high bit clock value calculation operator module provided according to an embodiment of the present disclosure;

fig. 6 is a flowchart of a bluetooth clock calculation method provided according to an embodiment of the present disclosure.

Detailed Description

The following detailed description of specific embodiments of the present disclosure is provided in connection with the accompanying drawings. It should be understood that the detailed description and specific examples, while indicating the present disclosure, are given by way of illustration and explanation only, not limitation.

As described in the background, bluetooth clocks are currently generally obtained by both hardware reading and software computation.

In the hardware reading mode, the value of a hardware register BT _ CLK (Bluetooth clock) is read, the register records the Bluetooth clock of the current classic Bluetooth link, so that the classic Bluetooth link needing to be accessed needs to be the same link as the current baseband hardware works, and otherwise the classic Bluetooth link cannot be used. This results in the inability to acquire the bluetooth clock of the classic bluetooth link B while the baseband hardware is operating on classic bluetooth link a, and thus, this approach, while simple, has limitations. Furthermore, the clock accuracy of BT _ CLK is 321.5 microseconds, and a bluetooth clock with an accuracy of 1 microsecond cannot be obtained.

In the software calculation mode, software needs to read a hardware register NATIVE _ BT _ CLK (local Bluetooth clock) first to obtain a current local Bluetooth clock, wherein the precision is 312.5 microseconds and the range is 0-0 xfffffff, and then reads a hardware register NATIVE _ BITCT (count value of a local microsecond counter) to obtain a value of the current local Bluetooth clock microsecond counter, wherein the precision is 1 microsecond and the range is 0-1249. When NATIVE _ BITCT counts to 312, 625, 937, 1249, bit [1:0] of NATIVE _ BT _ CLK makes a transition, corresponding to b '01' (representing a binary number "01", other synonyms), b '10', b '11', b '00', respectively. When bits [1:0] of NATIVE _ BT _ CLK jump from b '11' to b '00', bits [27:2] of NATIVE _ BT _ CLK are incremented by 1. Wherein, the Bluetooth clock can be represented by 28 bits (equivalent to a counter of 28 bits), and bit [ i: j ] represents from j th bit to i th bit, so bit [1:0] represents from 0 th bit (lowest bit) to 1 st bit (second lowest bit), and bit [27:2] represents from 2 nd bit to 27 th bit. Because the software has a sequence when reading the NATIVE _ BT _ CLK and the NATIVE _ BITCNT and cannot access the same as the hardware at the same time, the problem that the value of the NATIVE _ BT _ CLK jumps when the software reads the NATIVE _ BITCNT needs to be considered. For example, when the value of NATIVE _ BITCT is determined to be less than 312, it is suspected that the bit [27:2] of NATIVE _ BT _ CLK may have changed, and the values of NATIVE _ BT _ CLK and NATIVE _ BITCT may need to be re-read.

In addition, when software reads the NATIVE _ BT _ CLK, the jitter problem needs to be considered, and the software needs to acquire the data for de-jitter processing for multiple times. And finally, calculating the current Bluetooth clock corresponding to the classic Bluetooth link by using a Bluetooth clock calculation formula. And, adopt the software mode to calculate the bluetooth clock, still can receive the influence of CPU frequency. The calculation time is shorter as the CPU frequency is higher. Otherwise, the longer the calculation time.

Therefore, the software calculation method requires complicated data processing and takes a long time.

In order to solve the above problems, the present disclosure provides a bluetooth clock calculation circuit, a bluetooth clock calculation method, a medium, and an apparatus, which can simply and quickly obtain a current bluetooth clock of any classic bluetooth link at any time.

Fig. 1 is a schematic structural diagram of a bluetooth clock calculation circuit provided according to an embodiment of the present disclosure. As shown in fig. 1, the bluetooth clock calculation circuit 10 may include:

the starting module 11 is used for starting the Bluetooth clock calculation circuit when receiving the Bluetooth clock calculation instruction;

the acquisition module 12 is configured to acquire a first clock value of a local bluetooth clock and a first count value of a first microsecond counter of the local bluetooth clock when the bluetooth clock calculation circuit is started;

the first calculating module 13 is configured to determine a second count value corresponding to the first microsecond counter when a second microsecond counter of the target bluetooth clock is 0;

the second calculating module 14 is configured to determine a target count value of the target bluetooth clock according to the first count value;

the third calculating module 15 is configured to determine a target clock value of the target bluetooth clock according to the first clock value, the second count value, and the target count value;

and the output module 16 is used for outputting the target count value and the target clock value to a sender of the bluetooth clock calculation instruction.

A sender (e.g., software) of the bluetooth clock calculation instruction may send the bluetooth clock calculation instruction to the bluetooth clock calculation circuit to trigger the start module 11 to start the bluetooth clock calculation circuit, and after the bluetooth clock calculation circuit is started, the calculation is started.

Under the condition that the Bluetooth clock calculation circuit is started, the acquisition module periodically acquires a clock value of a local Bluetooth clock as a first clock value, and also periodically acquires a count value of a microsecond counter (namely, a first microsecond counter) of the local Bluetooth clock as a first count value. It should be noted that the subsequent calculation is performed on the first clock value and the first count value acquired in the same acquisition cycle, and the data acquired in each acquisition cycle may be calculated in the same manner for a plurality of times.

Alternatively, as shown in fig. 2, the first calculation module 13 may include:

a first subtractor 131, configured to calculate a first difference value obtained by subtracting the time difference indicated by the first time difference information from a first preset value;

the first carry processing sub-module 132 is configured to perform a remainder operation using the first difference and a second preset value to obtain a second count value.

The first time difference information is used for representing the time difference between the second microsecond counter being at 0 microsecond and the first microsecond counter being at a preset microsecond value. The preset microsecond value is a value corresponding to the middle point of the counting range of the first microsecond counter. Illustratively, the preset microsecond value may be 625 (microseconds). For example, the first time difference information may be provided directly to the bluetooth clock calculation circuit by a sender (e.g., software) of the bluetooth clock calculation instruction. For example, the bluetooth clock calculation instruction may carry the first time difference information. Wherein, the time difference range indicated by the first time difference information is [0, 1249], and the precision is 1 microsecond.

For example, the second count value native _ bit _ cnt (bit _ cnt ═ 0) may be calculated by the following equation:

native_bit_cnt(bit_cnt=0)=(D1-intraslot_offset)%D2

wherein D1 is a first predetermined value, intraburst _ offset is a time difference indicated by the first time difference information, and D2 is a second predetermined value. Wherein, (D1-intrastalot _ offset) represents the operation performed by the first subtractor 131, and the obtained value is the first difference value, (the first difference value% D2) represents the operation performed by the first carry processing sub-module 132. The second preset value D2 may be determined according to a counting range of the second microsecond counter at the current precision. For example, in the case of an accuracy of 1 microsecond, the count range of the second microsecond counter is 0 to 1249, totaling 1250, and therefore D2 can take 1250. The first preset value D1 can be derived according to the second preset value D2, and generally, half of the second preset value D2 can be regarded as the first preset value D1. For example, if D2 is 1250, then D1 may take 625. In addition, considering that the first preset value D1 needs to be different from intrasite _ offset, and intrasite _ offset may be larger than half of the second preset value D2, in order to avoid increasing the operation amount due to negative number in the operation, when the first preset value D1 is taken, D1 may be 3/2 × D2, and this has no influence on the final result. For example, if D2 is 1250, D1 may take 1875.

Alternatively, as shown in fig. 3, the second calculation module 14 may include:

a first adder 141, configured to calculate a first sum of the third preset value, the time difference indicated by the first time difference information, and the first count value;

and the second carry processing submodule 142 is configured to perform a remainder operation on the first sum and a fourth preset value to obtain a target count value.

For example, the target count value BIT _ CNT may be calculated by the following equation:

BIT_CNT=(D3+intraslot_offset+native_bit_cnt)%D4

wherein D3 is the third predetermined value, intraburst _ offset is the time difference indicated by the first time difference information, and D4 is the fourth predetermined value. Wherein, (D3+ intrasite _ offset + native _ bit _ cnt) represents the operation performed by the first adder 141, and the obtained sum is a first sum value, and (the first sum value% D4) represents the operation performed by the second carry processing submodule 142. The fourth preset value D4 may be determined according to the counting range of the second microsecond counter at the current accuracy. For example, in the case of an accuracy of 1 microsecond, the count range of the second microsecond counter is 0 to 1249, totaling 1250, and therefore D4 can take 1250. The third preset value D3 can be derived according to the fourth preset value D4, and generally, half of the fourth preset value D4 can be regarded as the third preset value D3. For example, if D4 is 1250, then D3 may take 625.

As described above, the clock value of the bluetooth clock is represented by a preset number (e.g., 28) of bits, and the lowest N bits of the preset number of bits are low bits, and the other bits except the low bits of the preset number of bits are high bits, where N is a positive integer. Illustratively, N may be 2, so that the low bits are bit [1:0], and the high bits are bit [27:2 ]. For convenience of description, the example given hereinafter will be exemplified for the case where N is 2.

Alternatively, as shown in fig. 4, the third calculation module 15 may include:

a low bit clock value calculating operator module 151 for determining a first value of a low bit corresponding to the target bluetooth clock according to the target count value;

a high bit clock value calculation operator module 152 for determining a second value corresponding to the high bit of the target bluetooth clock according to the first clock value and the second count value;

and a target clock value determining submodule 153 for determining the target clock value according to the first value and the second value.

That is, the low bit clock value calculation operator module 151 determines a first value of a low bit corresponding to the target bluetooth clock, and the high bit clock value calculation operator module 152 determines a second value of a high bit corresponding to the target bluetooth clock, and then concatenates the two values to obtain the target clock value.

Alternatively, the low bit clock value operator module 151 may include:

the range judger is used for judging a numerical value interval in which the target counting value is positioned according to a plurality of preset numerical value intervals as a target numerical value interval;

and the first determining submodule is used for determining the bit value corresponding to the target numerical value interval as a first value according to the preset corresponding relation between the plurality of numerical value intervals and the plurality of kinds of bit values.

Illustratively, 4 value intervals may be preset, which are: [0, 312), [312, 625), [625, 937) and [937, 1250), and let [0, 312) correspond to b '00', let [312, 625) correspond to b '01', let [625, 937) correspond to b '10', let [937, 1250) correspond to b '11'. Thus, if the target count value is 600, the range determiner may determine that the target count value is in the value interval of [312, 625), that is, [312, 625) is the target value interval, and [312, 625) corresponds to b '01', and thus, may determine that the first value BT _ CLK [1:0] ═ b '01', that is, the lowest two bits of the target clock value are "01".

Alternatively, as shown in fig. 5, the high bit clock value operator module 152 may include:

a comparator 1521, configured to compare the first count value with the second count value, and obtain an output value according to the comparison result, where the output value is 0 if the first count value is greater than or equal to the second count value, and the output value is 1 if the first count value is smaller than the second count value;

a second subtractor 1522 configured to calculate a difference between a bit value corresponding to a higher-order bit in the first count value and the output value as a second difference;

a second adder 1523, configured to calculate a second sum value of the second difference value and the bit value of the upper bit corresponding to the time difference indicated by the second time difference information, and take the second sum value as a second value.

The comparator 1521 compares the magnitude of the first count value native _ bit _ cnt with the magnitude of the second count value native _ bit _ cnt (bit _ cnt is 0) to obtain an output value:

if native _ bit _ cnt > -native _ bit _ cnt (bit _ cnt ═ 0), the output value is 0;

if native _ bit _ cnt < native _ bit _ cnt (bit _ cnt ═ 0), the output value is 1.

For example, the second difference native _ bt _ clk [27:2] (bit _ cnt ═ 0) can be calculated by the following equation:

native_bt_clk[27:2](bit_cnt=0)=native_bt_clk[27:2]-output

where native _ bt _ clk [27:2] is the bit value corresponding to the upper bit in the first count value, and output is the output value, which may take 0 or 1. Wherein (native _ bt _ clk [27:2] -output) represents the operation performed by the second subtractor 1522, and the obtained value is a second difference value.

The second time difference information is used for indicating the time difference between the clock value corresponding to the target Bluetooth clock and the clock value of the local Bluetooth clock at the moment when the second microsecond counter is at the moment of 0 microsecond. For example, the second time difference information may be provided directly to the bluetooth clock calculation circuit by a sender (e.g., software) of the bluetooth clock calculation instruction. For example, the bluetooth clock calculation instruction may also carry second time difference information.

For example, the second sum (i.e., the second value) BT _ CLK [27:2] may be calculated by the following equation:

BT_CLK[27:2]=native_bt_clk[27:2](bit_cnt=0)+bt_clk_offset[27:2]

where native _ bt _ clk [27:2] (bit _ cnt ═ 0) is the second difference, and bt _ clk _ offset [27:2] is the bit value of the upper bit corresponding to the time difference indicated by the second time difference information. The (native _ bt _ clk [27:2] (bit _ cnt ═ 0) + bt _ clk _ offset [27:2]) represents the operation performed by the second adder 1523, and a second sum, that is, a second value, is obtained.

Optionally, the bluetooth clock calculation circuit 10 provided by the present disclosure may further include:

and the closing module is used for closing the Bluetooth clock calculation circuit after a sender of the Bluetooth clock calculation instruction reads the target count value and the target clock value from the output module.

If the sender of the Bluetooth clock calculation instruction reads the target count value and the target clock value from the output module, the Bluetooth clock calculation circuit can be turned off to stop calculation. And after the next Bluetooth clock calculation circuit is started, performing a new Bluetooth clock calculation according to the calculation mode. That is to say, the bluetooth clock calculation circuit provided by the present disclosure may continuously collect (cyclically collect) the first clock value and the first count value of the local bluetooth clock, and then calculate the target count value and the target clock value of the target bluetooth clock in the above manner, and the cyclic process is not stopped until the sender of the bluetooth clock calculation instruction triggers to turn off the bluetooth clock calculation circuit.

Through the technical scheme, the Bluetooth clock calculation circuit comprises a starting module, an acquisition module, a first calculation module, a second calculation module, a third calculation module and an output module. The starting module is used for starting the Bluetooth clock calculation circuit when receiving a Bluetooth clock calculation instruction; the acquisition module is used for acquiring a first clock value of a local Bluetooth clock and a first count value of a first microsecond counter of the local Bluetooth clock under the condition that the Bluetooth clock calculation circuit is started; the first calculating module is used for determining a second counting value corresponding to the first microsecond counter when the second microsecond counter of the target Bluetooth clock is 0; the second calculation module is used for determining a target count value of the target Bluetooth clock according to the first count value; the third calculating module is used for determining a target clock value of the target Bluetooth clock according to the first clock value, the second counting value and the target counting value; the output module is used for outputting the target count value and the target clock value to a sender of the Bluetooth clock calculation instruction. Therefore, the Bluetooth clock calculation circuit realized by hardware can acquire the current Bluetooth clock of any Bluetooth link at any time, and the calculation is simple and rapid.

Fig. 6 is a flowchart of a bluetooth clock calculation method provided according to an embodiment of the present disclosure. The method can be applied to the Bluetooth clock calculation circuit provided by any embodiment of the disclosure, wherein the Bluetooth clock calculation circuit comprises a starting module, an acquisition module, a first calculation module, a second calculation module, a third calculation module and an output module. As shown in fig. 6, the method may include the steps of:

in step 61, when receiving a bluetooth clock calculation instruction, acquiring a first clock value of a local bluetooth clock and a first count value of a first microsecond counter of the local bluetooth clock;

in step 62, determining a second count value corresponding to the first microsecond counter when the second microsecond counter of the target bluetooth clock is at 0;

in step 63, determining a target count value of the target bluetooth clock according to the first count value;

in step 64, determining a target clock value of the target bluetooth clock according to the first clock value, the second count value and the target count value;

in step 65, the target count value and the target clock value are output to the sender of the bluetooth clock calculation instruction.

Optionally, the bluetooth clock calculation instruction carries first time difference information, where the first time difference information is used to indicate a time difference between when the second microsecond counter is at 0 microsecond and when the first microsecond counter is at a preset microsecond value, and the preset microsecond value is a value corresponding to a midpoint of a counting range of the first microsecond counter;

determining a second count value corresponding to the first microsecond counter when a second microsecond counter of the target Bluetooth clock is at 0, comprising:

and calculating a first difference value obtained by subtracting the time difference indicated by the first time difference information from the first preset value, and performing a remainder operation by using the first difference value and a second preset value to obtain a second counting value.

Optionally, the bluetooth clock calculation instruction carries first time difference information, where the first time difference information is used to indicate a time difference between when the second microsecond counter is at 0 microsecond and when the first microsecond counter is at a preset microsecond value, and the preset microsecond value is a value corresponding to a midpoint of a counting range of the first microsecond counter;

determining a target count value of a target Bluetooth clock according to the first count value, comprising:

and calculating a first sum of the third preset value, the time difference indicated by the first time difference information and the first counting value, and performing remainder operation by using the first sum and the fourth preset value to obtain a target counting value.

Optionally, the clock value of the bluetooth clock is represented by a preset number of bits, and the lowest N bits of the preset number of bits are low bits, and the other bits except the low bits of the preset number of bits are high bits, where N is a positive integer;

determining a target clock value of the target Bluetooth clock according to the first clock value, the second count value and the target count value, wherein the method comprises the following steps:

determining a first value corresponding to a low bit of a target bluetooth clock based on the target count value;

determining a second value corresponding to a high bit of the target Bluetooth clock according to the first clock value and the second count value;

and determining a target clock value according to the first value and the second value.

With regard to the method in the above-mentioned embodiment, the specific manner of each step has been described in detail in the embodiment related to the bluetooth clock calculation circuit, and will not be elaborated here.

The present disclosure also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the bluetooth clock calculation method according to any of the embodiments of the present disclosure.

The present disclosure also provides an electronic device including the bluetooth clock calculation circuit according to any embodiment of the present disclosure.

The preferred embodiments of the present disclosure are described in detail with reference to the accompanying drawings, however, the present disclosure is not limited to the specific details of the above embodiments, and various simple modifications may be made to the technical solution of the present disclosure within the technical idea of the present disclosure, and these simple modifications all belong to the protection scope of the present disclosure.

It should be noted that the various features described in the above embodiments may be combined in any suitable manner without departing from the scope of the invention. In order to avoid unnecessary repetition, various possible combinations will not be separately described in this disclosure.

In addition, any combination of various embodiments of the present disclosure may be made, and the same should be considered as the disclosure of the present disclosure, as long as it does not depart from the spirit of the present disclosure.

16页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种电力监控系统的冗余监控装置

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!