Hi,
I am trying to use 1307 I2C clock in xmega256D3
I am getting this error,
Error : 5 Line : 167 No more space for BIT [TWI_START] , in File : C:Documents and SettingsAdministratorMy DocumentsMCS ElectronicsBASCOM-AVRSamplesXMEGADJB_XMEGA_1_ck.bas
Error : 320 Line : 167 [syntax error, token = '{'] , in File : C:Documents and SettingsAdministratorMy DocumentsMCS ElectronicsBASCOM-AVRSamplesXMEGADJB_XMEGA_1_ck.bas
My code is,
'------------------------------------------------------------------------------------------
$regfile = "xm256d3def.dat"
$crystal = 32000000
$hwstack = 64
$swstack = 64
$framesize = 64
Config Osc = Enabled , 32Mhzosc = Enabled
Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1 ' use 32 MHz
Config Clock = User ' we use I2C for the clock
'configure the scl and sda pins
Config Sda = Portc.0
Config Scl = Portc.1
'address of ds1307
Const Ds1307w = &HD0 ' Addresses of Ds1307 clock
Const Ds1307r = &HD1
'dim _day as byte, _month as byte , _year as byte
'dim _sec as byte, _min as byte, _hour as byte
' my other code is here.....
end
'===============================================================================
Dim Weekday As Byte
Getdatetime:
I2cstart ' Generate start code
I2cwbyte Ds1307w ' send address
I2cwbyte 0 ' start address in 1307
I2cstart ' Generate start code
I2cwbyte Ds1307r ' send address
I2crbyte _sec , Ack
I2crbyte _min , Ack ' MINUTES
I2crbyte _hour , Ack ' Hours
I2crbyte Weekday , Ack ' Day of Week
I2crbyte _day , Ack ' Day of Month
I2crbyte _month , Ack ' Month of Year
I2crbyte _year , Nack ' Year
I2cstop
_sec = Makedec(_sec) : _min = Makedec(_min) : _hour = Makedec(_hour)
_day = Makedec(_day) : _month = Makedec(_month) : _year = Makedec(_year)
Return
Setdate:
_day = Makebcd(_day) : _month = Makebcd(_month) : _year = Makebcd(_year)
I2cstart ' Generate start code
I2cwbyte Ds1307w ' send address
I2cwbyte 4 ' starting address in 1307
I2cwbyte _day ' Send Data to SECONDS
I2cwbyte _month ' MINUTES
I2cwbyte _year ' Hours
I2cstop
Return
Settime:
_sec = Makebcd(_sec) : _min = Makebcd(_min) : _hour = Makebcd(_hour)
I2cstart ' Generate start code
I2cwbyte Ds1307w ' send address
I2cwbyte 0 ' starting address in 1307
I2cwbyte _sec ' Send Data to SECONDS
I2cwbyte _min ' MINUTES
I2cwbyte _hour ' Hours
I2cstop
Return
'-------------------------------------------------------------------------------
What mistake, am I doing ?
I have used 1307 many times in 8052 , but AVR is new to me.
Regards,
Devidas
[b:0ff3125631][color=red:0ff3125631](BASCOM-AVR version : 2.0.7.6 )[/b:0ff3125631][/color:0ff3125631]
↧