I am developing a project that does a graphic line on GLCD of ADC values in real-time.
Here, I attach an small test program that executes similar lines that my project program.
Code: Select all
' MCU: P30F6014A
' Xtal: 10 Mhz
' Setup: Standard project
' Development board: dsPICPRO4
'
program TestGraph
dim x1, x2 as byte
dim y1, y2 as word
dim ADCconv as word
' Program init
sub procedure Init_Main()
ADPCFG = $FFFF
Glcd_Init_dsPICPro3
Glcd_Fill(0x00)
delay_ms(200)
ADPCFG = $FBFF
TRISB.10 = 1 ' RB10 as input pin
end sub
' Main procedure
main:
Init_Main()
X2 = 0
Y1 = 32
while true
'Read AI
ADCconv = Adc_Read(10)
delay_us(10)
'Line draw
Y2 = ADCconv * 64 / 4096
X1 = X2 - 1
Glcd_Line(x2, 0, x2, 63, 0)
Glcd_Line(x1, y1, x2, y2, 1)
Y1 = Y2
inc(X2)
if X2 > 127 then
X2 = 0
end if
delay_ms(10)
wend
end.
The problem is:
- If is the value greater that 2048 it's draw correctly,
- if is the value smaller that 2048, only draw a line in the midle of GLCD,
- if is the value greater that 2048 and it increases, draw correctly, but if decreases, only a count, the program is blocked.
I don't know if is a library problem or some error in my program.
Please, I need someone can help me with this problem.
Thanks.