structure pass parameter error

Beta Testing discussion on mikroBasic PRO for dsPIC30/33 and PIC24.
Post Reply
Author
Message
bpop
Posts: 7
Joined: 09 Dec 2009 17:19
Location: Belgium

structure pass parameter error

#1 Post by bpop » 18 Dec 2009 17:20

I'am getting this error "16 327 Incompatible types ("complex type" to "simple type") Stucture_test.mbas" when the called routine with the structure type is in a module.
program Stucture_test

include "Def_test_I2C1"

main:
dim ts1 as Time_Struct

ts1.ss = 55 'seconds
ts1.mn = 59 'minutes
ts1.hh = 23 'hours
ts1.wd = 7 'weekday
ts1.md = 31 'day
ts1.mo = 12 'month
ts1.yy = 09 'year

I2C_Set_Time(ts1)

end.

module Def_test_I2C1

structure Time_Struct
dim ss as byte ' seconds
dim mn as byte ' minutes
dim hh as byte ' hours
dim wd as byte ' day in week, 1 to 7
dim md as byte ' day in month, 1 to 31
dim mo as byte ' month, 1 to 12
dim yy as byte ' year 00-99
end structure

sub procedure I2C_Set_Time (dim byref ts2 as Time_Struct)

implements

sub procedure I2C_Set_Time (dim byref ts2 as Time_Struct)
' ts2.ss = (((ts2.ss div 10) and 0x07) << 4) or (ts2.ss mod 10)
' ts2.mn = (((ts2.mn div 10) and 0x07) << 4) or (ts2.mn mod 10)
' ts2.hh = (((ts2.hh div 10) and 0x03) << 4) or (ts2.hh mod 10)
' ts2.wd = (((ts2.wd div 10) and 0x00) << 4) or (ts2.wd mod 10)
' ts2.md = (((ts2.md div 10) and 0x03) << 4) or (ts2.md mod 10)
' ts2.mo = (((ts2.mo div 10) and 0x01) << 4) or (ts2.mo mod 10)
' ts2.yy = (((ts2.yy div 10) and 0x0F) << 4) or (ts2.yy mod 10)

RCON.5 = 1 ' enable SWDTEN
' address = %11010000 ' slave RTC address 1101 x A1 A0 RnW
I2C1_Start()
I2C1_Write(0xD0)
I2C1_Write(0x00) ' Start from word at address 0
I2C1_Write(0x02) ' Set W bit = 1 reg 0x00
I2C1_Write(0x80) ' CAL/Control reg 0x01
I2C1_Stop() ' Issue stop signal
I2C1_Start() ' Issue start signal
I2C1_Write(0xD0) ' send address for write
I2C1_Write(0x02) ' Start from word at address 2
I2C1_Write(ts2.ss) ' Write seconds reg 0x02
I2C1_Write(ts2.mn) ' Write minutes reg 0x03
I2C1_Write(ts2.hh) ' Write hours reg 0x04
I2C1_Write(ts2.wd) ' Write weekday reg 0x05
I2C1_Write(ts2.md) ' Write date reg 0x06
I2C1_Write(ts2.mo) ' Write month reg 0x07
I2C1_Write(ts2.yy) ' Write year reg 0x08
I2C1_Stop() ' Issue stop signal
I2C1_Start() ' Issue start signal
I2C1_Write(0xD0) ' Address
I2C1_Write(0x00) ' Start from word at address 0
I2C1_Write(0x00) ' Write 0 to config. byte
I2C1_Write(0x00) ' CAL/Control reg 0x01
I2C1_Stop() ' Issue stop signal
RCON.5 = 0 ' disable SWDTEN
end sub

end.
However, when the routine is included in the main program, it will compile without errors.
program Stucture_test

include "Def_test_I2C1"

sub procedure I2C_Set_Time (dim byref ts2 as Time_Struct)
' ts2.ss = (((ts2.ss div 10) and 0x07) << 4) or (ts2.ss mod 10)
' ts2.mn = (((ts2.mn div 10) and 0x07) << 4) or (ts2.mn mod 10)
' ts2.hh = (((ts2.hh div 10) and 0x03) << 4) or (ts2.hh mod 10)
' ts2.wd = (((ts2.wd div 10) and 0x00) << 4) or (ts2.wd mod 10)
' ts2.md = (((ts2.md div 10) and 0x03) << 4) or (ts2.md mod 10)
' ts2.mo = (((ts2.mo div 10) and 0x01) << 4) or (ts2.mo mod 10)
' ts2.yy = (((ts2.yy div 10) and 0x0F) << 4) or (ts2.yy mod 10)

RCON.5 = 1 ' enable SWDTEN
' address = %11010000 ' slave RTC address 1101 x A1 A0 RnW
I2C1_Start()
I2C1_Write(0xD0)
I2C1_Write(0x00) ' Start from word at address 0
I2C1_Write(0x02) ' Set W bit = 1 reg 0x00
I2C1_Write(0x80) ' CAL/Control reg 0x01
I2C1_Stop() ' Issue stop signal
I2C1_Start() ' Issue start signal
I2C1_Write(0xD0) ' send address for write
I2C1_Write(0x02) ' Start from word at address 2
I2C1_Write(ts2.ss) ' Write seconds reg 0x02
I2C1_Write(ts2.mn) ' Write minutes reg 0x03
I2C1_Write(ts2.hh) ' Write hours reg 0x04
I2C1_Write(ts2.wd) ' Write weekday reg 0x05
I2C1_Write(ts2.md) ' Write date reg 0x06
I2C1_Write(ts2.mo) ' Write month reg 0x07
I2C1_Write(ts2.yy) ' Write year reg 0x08
I2C1_Stop() ' Issue stop signal
I2C1_Start() ' Issue start signal
I2C1_Write(0xD0) ' Address
I2C1_Write(0x00) ' Start from word at address 0
I2C1_Write(0x00) ' Write 0 to config. byte
I2C1_Write(0x00) ' CAL/Control reg 0x01
I2C1_Stop() ' Issue stop signal
RCON.5 = 0 ' disable SWDTEN
end sub

main:
dim ts1 as Time_Struct

ts1.ss = 55 'seconds
ts1.mn = 59 'minutes
ts1.hh = 23 'hours
ts1.wd = 7 'weekday
ts1.md = 31 'day
ts1.mo = 12 'month
ts1.yy = 09 'year

I2C_Set_Time(ts1)

end.

module Def_test_I2C1

structure Time_Struct
dim ss as byte ' seconds
dim mn as byte ' minutes
dim hh as byte ' hours
dim wd as byte ' day in week, 1 to 7
dim md as byte ' day in month, 1 to 31
dim mo as byte ' month, 1 to 12
dim yy as byte ' year 00-99
end structure

implements
end.

:roll:

peterverkaik
Posts: 174
Joined: 31 Aug 2009 22:44

#2 Post by peterverkaik » 18 Dec 2009 17:25

Have you added the module source file (*.dbas) to section
Sources in ProjectManager?

regards peter

bpop
Posts: 7
Joined: 09 Dec 2009 17:19
Location: Belgium

#3 Post by bpop » 18 Dec 2009 17:45

Yes, the file is included in the project search path. I guess if something was wrong with the search path, it would not find the initialization of the stucture.

User avatar
anikolic
mikroElektronika team
Posts: 1775
Joined: 17 Aug 2009 16:51
Location: Belgrade
Contact:

#4 Post by anikolic » 21 Dec 2009 11:07

I'am getting this error "16 327 Incompatible types ("complex type" to "simple type") Stucture_test.mbas" when the called routine with the structure type is in a module.
I informed our developers of this issue, and they will take a look at this problem. If this turns to be a compiler bug, be absolutely sure that this will be corrected in the final release. I will inform you of the results in this topic. Thank you very much for reporting this.

Best regards,
Aleksandar
Web Department Manager

bpop
Posts: 7
Joined: 09 Dec 2009 17:19
Location: Belgium

#5 Post by bpop » 21 Dec 2009 11:19

It seems to work when I move the dim statement for the main variable to the interface section of the module.

User avatar
anikolic
mikroElektronika team
Posts: 1775
Joined: 17 Aug 2009 16:51
Location: Belgrade
Contact:

#6 Post by anikolic » 21 Dec 2009 12:04

Hi,
There was a problem with passing structures as function parameters. Solved for the final release.

Best regards,
Aleksandar
Web Department Manager

Post Reply

Return to “mikroBasic PRO for dsPIC30/33 and PIC24 Beta Testing”