problem in variable management

General discussion on mikroBasic PRO for PIC32.
Post Reply
Author
Message
Rbasile
Posts: 7
Joined: 11 Nov 2017 18:49

problem in variable management

#1 Post by Rbasile » 09 Sep 2019 13:57

Hi
when i add a new variable my program don't run as expected after.
i need to manualy atribute most of my variable to a spesific location in ram with the atribute "absolute" and even doing that it work only some time.
did i make a mistake in the configuration? or it's a bug of the compiller

i use a PIC32MZ0512EFF064
here my config register
DEVCFG3 : $1FC0FFC0 : 0x79000000
DEVCFG2 : $1FC0FFC4 : 0x40023B21
DEVCFG1 : $1FC0FFC8 : 0x5F74C6B9
DEVCFG0 : $1FC0FFCC : 0x403FF777

and i use level 4 with SSA in the optimisation parameter

thanks

Basile

Rbasile
Posts: 7
Joined: 11 Nov 2017 18:49

Re: problem in variable management

#2 Post by Rbasile » 12 Sep 2019 22:43

I'm using the Fat32 lib, and it's mostly the function I wrote to read an image or file in an SD card that malfunctioning when I adding new variables to make me over function

and assining each variable to a spesific place with "absolute" don't work finnaly

for example i just wrote a new function with 3 local variable and using also a global variable
if i call this new function it make my previous function not working

Code: Select all

sub procedure imageDisp(dim byref imgname as string)
fhandle = FAT32_Open(@imgname, FILE_READ_F32)
FAT32_Seek(fhandle, $A)
FAT32_Read(fhandle, @lineBuff, 3)
'UART1_Write(lineBuff[0])
stImage = lineBuff[0]
FAT32_Seek(fhandle,stImage)
for iL = 120 to 0 step -10
  FAT32_Read(fhandle, @lineBuff, 32)
  iI=0
  for iR = 0 to 29 step 3
    LEDdata[iI+iL][2] =  lineBuff[iR]
    LEDdata[iI+iL][1] = lineBuff[iR+1]
    LEDdata[iI+iL][0] = lineBuff[iR+2]
    inc(iI)
  next iR
next iL
FAT32_Close(fHandle)
ledshow()
delay_ms(20)
end sub

sub procedure imageChar(dim byref charnameND as string)
fhandle = FAT32_Open(@charnameND, FILE_READ_F32)
FAT32_Seek(fhandle, $A)
FAT32_Read(fhandle, @lineBuff, 3)
'UART1_Write(lineBuff[0])
stImage = lineBuff[0]
FAT32_Seek(fhandle,stImage)
for iL = 120 to 0 step -10
  FAT32_Read(fhandle, @lineBuff, 32)
  iI=0
  for iR = 0 to 29 step 3
    LEDdata[iI+iL][2] =  lineBuff[iR]
    LEDdata[iI+iL][1] = lineBuff[iR+1]
    LEDdata[iI+iL][0] = lineBuff[iR+2]
    inc(iI)
  next iR
next iL
FAT32_Close(fHandle)
ledshow()
end sub


sub procedure textD(dim byref texttoD as string,dim speedD as word)
dim tlong as byte
dim ichar as byte
dim charac as string[6]
dirname = "\"
FAT32_ChangeDir(@dirname)
dirname = "alpha"
FAT32_ChangeDir(@dirname)
tlong = length(texttoD)-1
for ichar = 0 to tlong
if texttoD[ichar] = " " then
  charac = "sp.bmp"
else
  charac = "0.bmp"
  charac[0] = texttoD[ichar]
end if
imageChar(charac)

Vdelay_ms(speedD)
next ichar
end sub

Sub procedure seqima(dim byref directo as string)
dim nnext as integer
dim nameNum as string[8]
dim nName as word
dim Home as char
Home = "\"
FAT32_ChangeDir(@Home)
FAT32_ChangeDir(@directo)
nName = 0
while 1
inc(nName)
WordToStrWithZeros(nName,nameNum)
nameNum[0]=nameNum[1]
nameNum[1]=nameNum[2]
nameNum[2]=nameNum[3]
nameNum[3]=nameNum[4]
nameNum[4]="."
nameNum[5]="b"
nameNum[6]="m"
nameNum[7]="p"
nnext = FAT32_Exists(@nameNum)
if nnext = 0 then break end if
imageDisp(@nameNum)
wend

end sub
the 3 first functions are working if i don't call the last one in my main program


i change some variable of place and removed a "FAT32_ChangeDir(@dirname)"
now it's working when i call the last

Code: Select all

sub procedure imageDisp(dim byref imgname as string)
dim iR as byte 'absolute 0xA0000053
dim iL as byte 'absolute 0xA0000054
dim iI as byte 'absolute 0xA0000055
dim stImage as word absolute 0xA0000056
dim lineBuff as byte[32] 'absolute 0xA0000058

fhandle = FAT32_Open(@imgname, FILE_READ_F32)
FAT32_Seek(fhandle, $A)
FAT32_Read(fhandle, @lineBuff, 3)
'UART1_Write(lineBuff[0])
stImage = lineBuff[0]
FAT32_Seek(fhandle,stImage)
for iL = 120 to 0 step -10
  FAT32_Read(fhandle, @lineBuff, 32)
  iI=0
  for iR = 0 to 29 step 3
    LEDdata[iI+iL][2] =  lineBuff[iR]
    LEDdata[iI+iL][1] = lineBuff[iR+1]
    LEDdata[iI+iL][0] = lineBuff[iR+2]
    inc(iI)
  next iR
next iL
FAT32_Close(fHandle)
ledshow()
delay_ms(20)
end sub

sub procedure imageChar(dim byref charnameND as string)
dim iR as byte 'absolute 0xA0000053
dim iL as byte 'absolute 0xA0000054
dim iI as byte 'absolute 0xA0000055
dim stImage as word absolute 0xA0000056
dim lineBuff as byte[32] 'absolute 0xA0000058

fhandle = FAT32_Open(@charnameND, FILE_READ_F32)
FAT32_Seek(fhandle, $A)
FAT32_Read(fhandle, @lineBuff, 3)
'UART1_Write(lineBuff[0])
stImage = lineBuff[0]
FAT32_Seek(fhandle,stImage)
for iL = 120 to 0 step -10
  FAT32_Read(fhandle, @lineBuff, 32)
  iI=0
  for iR = 0 to 29 step 3
    LEDdata[iI+iL][2] =  lineBuff[iR]
    LEDdata[iI+iL][1] = lineBuff[iR+1]
    LEDdata[iI+iL][0] = lineBuff[iR+2]
    inc(iI)
  next iR
next iL
FAT32_Close(fHandle)
ledshow()
end sub


sub procedure textD(dim byref texttoD as string,dim speedD as word)
dim tlong as byte
dim ichar as byte
dim charac as string[6]
dirname = "\"
FAT32_ChangeDir(@dirname)
dirname = "alpha"
FAT32_ChangeDir(@dirname)

tlong = length(texttoD)-1
for ichar = 0 to tlong


if texttoD[ichar] = " " then
  charac = "sp.bmp"
else
  charac = "0.bmp"
  charac[0] = texttoD[ichar]
end if
imageChar(charac)

Vdelay_ms(speedD)
next ichar

end sub


Sub procedure seqima()
dim nnext as integer
dim nameNum as string[8]
dim nName as word
nName = 0
while 1
inc(nName)
WordToStrWithZeros(nName,nameNum)
nameNum[0]=nameNum[1]
nameNum[1]=nameNum[2]
nameNum[2]=nameNum[3]
nameNum[3]=nameNum[4]
nameNum[4]="."
nameNum[5]="b"
nameNum[6]="m"
nameNum[7]="p"
nnext = FAT32_Exists(@nameNum)

if nnext = 0 then break end if
imageDisp(@nameNum)

wend
end sub
but if i remove the 2 line

Code: Select all

nnext = FAT32_Exists(@nameNum)
if nnext = 0 then break end if
at the end off the function "seqima()"
it's not working again

I am starting losing my mind
if someone could help me
thanks all

Basile
ps sorry for my english

User avatar
filip.grujcic
Posts: 822
Joined: 14 May 2018 08:34

Re: problem in variable management

#3 Post by filip.grujcic » 13 Sep 2019 08:30

Hi,

I believe your configuration bits are wrong.
Could you zip and attach your project?
Also, which oscillator are you using?

Kind regards,
Filip Grujcic

Rbasile
Posts: 7
Joined: 11 Nov 2017 18:49

Re: problem in variable management

#4 Post by Rbasile » 13 Sep 2019 11:24

Hi
here are my project and the schematic of the board
i use a 20mhz quartz
schematic.jpg
schematic.jpg (588.86 KiB) Viewed 2018 times
the code it's a little mess up
it can clean it if you want

thanks

Basile
Attachments
Led Mask.zip
(862.31 KiB) Downloaded 80 times

User avatar
filip.grujcic
Posts: 822
Joined: 14 May 2018 08:34

Re: problem in variable management

#5 Post by filip.grujcic » 16 Sep 2019 09:02

Hello,

I'm not sure what the issue is.
I will have to look into it further, perhaps even order this chip, so I can try on real hardware.

I apologize for the inconvenience.

Kind regards,
Filip Grujcic

Post Reply

Return to “mikroBasic PRO for PIC32 General”