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.
Tool/software: TI C/C++ Compiler
Hi, I'm testing the ILPFC project and it's written in assembly and C.
Below codes are in "ADCDRV_1ch.asm"
ADCDRV_1ch_INIT .macro n
;================================
_ADCDRV_1ch_Rlt:n: .usect "ADCDRV_1ch_Section",2,1,1 ; 2 means 2 words, 32bits
; 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
Together with the code below, we defined 11 variable ADCDRV_1ch_Rlt1-ADCDRV_1ch_Rlt11, these variables' size are 2 words.
ADCDRV_1ch_INIT 1 ; Ipfc//these codes are in ILPFC-DPL-ISR.asm
ADCDRV_1ch_INIT 2 ; Ipfc
ADCDRV_1ch_INIT 3 ; Ipfc
ADCDRV_1ch_INIT 4 ; Ipfc
ADCDRV_1ch_INIT 5 ; Ipfc
ADCDRV_1ch_INIT 6 ; Ipfc
ADCDRV_1ch_INIT 7 ; Ipfc
ADCDRV_1ch_INIT 8 ; Ipfc
ADCDRV_1ch_INIT 9 ; Vpfc
ADCDRV_1ch_INIT 10 ; VL_fb
ADCDRV_1ch_INIT 11 ; VN_fb
In ILPFC-main.c, there are codes below.
// ADC Driver Macro. Ipfc is oversampled 8 times.
extern volatile long *ADCDRV_1ch_Rlt1; // instance #1, Ipfc
extern volatile long *ADCDRV_1ch_Rlt2; // instance #2, Ipfc
extern volatile long *ADCDRV_1ch_Rlt3; // instance #3, Ipfc
extern volatile long *ADCDRV_1ch_Rlt4; // instance #4, Ipfc
extern volatile long *ADCDRV_1ch_Rlt5; // instance #5, Ipfc
extern volatile long *ADCDRV_1ch_Rlt6; // instance #6, Ipfc
extern volatile long *ADCDRV_1ch_Rlt7; // instance #7, Ipfc
extern volatile long *ADCDRV_1ch_Rlt8; // instance #4, Ipfc
extern volatile long *ADCDRV_1ch_Rlt9; // instance #5, Vbus
extern volatile long *ADCDRV_1ch_Rlt10; // instance #6, VL_fb
extern volatile long *ADCDRV_1ch_Rlt11; // instance #7, VN_fb
My question is that:
Is it the code "extern volatile long *ADCDRV_1ch_Rlt1" makes the variable "ADCDRV_1ch_Rlt1" a pointer?
And I can also write "extern volatile long ADCDRV_1ch_Rlt1" to make the variable "ADCDRV_1ch_Rlt1" a long number, right?
But I cannot write "extern volatile int ADCDRV_1ch_Rlt1" to make the variable "ADCDRV_1ch_Rlt1" a short number, because short number is 16bits, and in assembly "ADCDRV_1ch_Rlt1" are allocated 32 bits, right?
The only C declaration which makes sense is "extern volatile long ADCDRV_1ch_Rlt1". It's not a pointer. It's a long value.
Thanks and regards,
-George
Accessing a hand-coded-assembly field from C code is tricky. You are better off defining the object in C code and accessing it from assembly, for two reasons: