Other Parts Discussed in Thread: AM3359
hello,
I use clpru compiler for am3359's PRU. Here is a code which seems to work in a wrong way:
volatile long long time=0, adcTime=0;
while (1) { adcTime = time; time+=1000; if (time >= adcTime + (long long)(20000)) { msg(time, adcTime); break; } }
"if" fires when (adcTime + 20000) becomes greater when 2^32.
msg: 4294949000( 4294948000 )
here asm part:
;* --------------------------------------------------------------------------*
;* BEGIN LOOP ||$C$L18||
;*
;* Loop source line : 136
;* Loop closing brace source line : 144
;* Known Minimum Trip Count : 1
;* Known Maximum Trip Count : 4294967295
;* Known Max Trip Count Factor : 1
;* --------------------------------------------------------------------------*
||$C$L18||:
.dwpsn file "pru_main.c",line 137,column 3,is_stmt,isa 0
LDI r0, ||time|| ; [ALU_PRU] |137| time
LBBO &r0, r0, 0, 8 ; [ALU_PRU] |137|
SBBO &r0, r2, 68, 8 ; [ALU_PRU] |137| adcTime
.dwpsn file "pru_main.c",line 139,column 3,is_stmt,isa 0
LDI r14, ||time|| ; [ALU_PRU] |139| time
LDI r16, 0x03e8 ; [ALU_PRU] |139|
ZERO &r15, 4 ; [ALU_PRU] |139|
LBBO &r0, r14, 0, 8 ; [ALU_PRU] |139|
ADD r0, r16, r0 ; [ALU_PRU] |139|
ADC r1, r15, r1 ; [ALU_PRU] |139|
SBBO &r0, r14, 0, 8 ; [ALU_PRU] |139|
.dwpsn file "pru_main.c",line 140,column 3,is_stmt,isa 0
LDI r15, 0x4e20 ; [ALU_PRU] |140|
ZERO &r14, 4 ; [ALU_PRU] |140|
LBBO &r0, r2, 68, 8 ; [ALU_PRU] |140| adcTime
ADC r14, r14, r1 ; [ALU_PRU] |140|
ADD r15, r15, r0 ; [ALU_PRU] |140|
XOR r14.b3, r14.b3, 0x80 ; [ALU_PRU] |140|
LDI r0, ||time|| ; [ALU_PRU] |140| time
LBBO &r0, r0, 0, 8 ; [ALU_PRU] |140|
XOR r1.b3, r1.b3, 0x80 ; [ALU_PRU] |140|
QBLT ||$C$L18||, r14, r1 ; [ALU_PRU] |140|
;* --------------------------------------------------------------------------*
QBGT ||$C$L19||, r14, r1 ; [ALU_PRU] |140|
;* --------------------------------------------------------------------------*
QBLT ||$C$L18||, r15, r0 ; [ALU_PRU] |140|
;* --------------------------------------------------------------------------*
I'm not so good at asm to understand is right or not. Or may be there is my misunderstanding?