TI中文支持网
TI专业的中文技术问题搜集分享网站

请问 ADCDRV_1ch Q格式问题

This assembly  macro  reads  a  result  from  the  internal  ADC  module  Result Register:n:  and  delivers  it  in  Q24  format to the  output  terminal,  where  :n:  is the  instance  number.  The  output  is  normalized  to  0-1.0  such  that  the minimum input voltage will generate nominally 0.0 at the driver output, and amaximum full  scale  input voltage  read  +1.0.  The  result  is  then  stored  in  the memory location pointed to by the net terminal pointer.

上面的红色文字是说把输出结果归一化到0-1.0这个范围,但是下面汇编没有看到如何把输入电压结果归一化的。

ADCDRV_1ch_INIT    .macro n
;================================
_ADCDRV_1ch_Rlt:n:    .usect "ADCDRV_1ch_Section",2,1,1    ; output terminal 1

; publish Terminal Pointers for access from the C environment
        .def     _ADCDRV_1ch_Rlt:n:

        MOVL    XAR2, #ZeroNet                        ; "ZeroNet" is initialised to 0 in ISR
        MOVW    DP, #_ADCDRV_1ch_Rlt:n:
        MOVL    @_ADCDRV_1ch_Rlt:n:, XAR2            ; zero output terminal pointer
        .endm

ADCDRV_1ch        .macro    n
;=============================
         MOVW    DP, #_ADCDRV_1ch_Rlt:n:                ; Load Data Page
        MOVL    XAR0,@_ADCDRV_1ch_Rlt:n:            ; Load Rlt Data Page Pointer in XAR0
        
        MOVW     DP, #_AdcResult                     ; load Data Page to read ADC results
        MOV     ACC,@_AdcResult.ADCRESULT:n:<<12    ; read and shift the 12 bit ADC result by 12 bits to get Q24 value
       
        MOVL    *XAR0,ACC                            ; store result in output pointer location
        .endm
这个汇编程序如何把结果变成Q24格式的呢?这里结果左移12位不是变成Q12格式了吗?

谢谢

Victor Zheng:

我的理解是ADC的结果本身是12位的,左移12位后就是24位的,正好是Q24的0-1.0的范围。

This assembly  macro  reads  a  result  from  the  internal  ADC  module  Result Register:n:  and  delivers  it  in  Q24  format to the  output  terminal,  where  :n:  is the  instance  number.  The  output  is  normalized  to  0-1.0  such  that  the minimum input voltage will generate nominally 0.0 at the driver output, and amaximum full  scale  input voltage  read  +1.0.  The  result  is  then  stored  in  the memory location pointed to by the net terminal pointer.

上面的红色文字是说把输出结果归一化到0-1.0这个范围,但是下面汇编没有看到如何把输入电压结果归一化的。

ADCDRV_1ch_INIT    .macro n
;================================
_ADCDRV_1ch_Rlt:n:    .usect "ADCDRV_1ch_Section",2,1,1    ; output terminal 1

; publish Terminal Pointers for access from the C environment
        .def     _ADCDRV_1ch_Rlt:n:

        MOVL    XAR2, #ZeroNet                        ; "ZeroNet" is initialised to 0 in ISR
        MOVW    DP, #_ADCDRV_1ch_Rlt:n:
        MOVL    @_ADCDRV_1ch_Rlt:n:, XAR2            ; zero output terminal pointer
        .endm

ADCDRV_1ch        .macro    n
;=============================
         MOVW    DP, #_ADCDRV_1ch_Rlt:n:                ; Load Data Page
        MOVL    XAR0,@_ADCDRV_1ch_Rlt:n:            ; Load Rlt Data Page Pointer in XAR0
        
        MOVW     DP, #_AdcResult                     ; load Data Page to read ADC results
        MOV     ACC,@_AdcResult.ADCRESULT:n:<<12    ; read and shift the 12 bit ADC result by 12 bits to get Q24 value
       
        MOVL    *XAR0,ACC                            ; store result in output pointer location
        .endm
这个汇编程序如何把结果变成Q24格式的呢?这里结果左移12位不是变成Q12格式了吗?

谢谢

11 12:

回复 Victor Zheng:

好的,谢谢,让我再理解一下代码

赞(0)
未经允许不得转载:TI中文支持网 » 请问 ADCDRV_1ch Q格式问题
分享到: 更多 (0)