I have implemented the BAS and INC files provided by Miles from Ciseco. I have analysed these in detail and haven't found any errors or issues. Using these some of the Swordfish samples work and others don't.
In order to get some of the samples to compile I have added some 18F25K22 code to SetAllDigital in utils.bat as follows:
#elseif _device in (18F25K22)
ANSELA=0
ANSELB=0
ANSELC=0
I can program the 18F25K22 using either a PicKit or by installing the DS30 bootloader. Some samples work when programmed with one and not the other and visa-versa.
The attached is the i2c sample program. In this case it works fine when programmed with the DS30 but doesn't work when exactly the same hex file is programmed with the PicKit. The same thing happens with the softwareI2C sample program. In both cases the scope shows that when programmed with the Pickit there is no activity at all on the SDA and SCL lines. The USART output works perfectly.
In trying to analyse what is happening in this and other examples, one possibility seems to be that some key registers in the 18F25K22 such as the ANSEL registers are not in the access bank but need an explicit bank select and subsequent deselect. However this is only supposition.
I would appreciate any help on this as this is a showstopper for me in terms of purchasing the full licence
Thanks
Peter
Code: Select all
// if device and clock are omitted, then the compiler defaults to
// 18F452 @ 20MHz - they are just used here for clarity...
Device = 18F25K22
Clock = 64
// import libraries...
Include "I2C.bas"
Include "usart.bas"
Include "utils.bas"
// target 24LC128 I2C EEPROM device...
Const I2C_EEPROM = $A0
// local variables...
Dim
Value As Byte,
Address As Word
// program start...
SetAllDigital()
Address = 55
I2C.Initialize
// write some data...
USART.SetBaudrate(br19200)
USART.Write("Start", 13, 10)
I2C.Start
I2C.WriteByte(I2C_EEPROM)
I2C.WriteByte(Address)
'I2C.WriteByte(Address.Byte0)
I2C.WriteByte("Z")
I2C.Stop
USART.Write("Sent", 13, 10)
// allow external EEPROM to write data...
DelayMS(40)
// read the data back...
I2C.Start
I2C.WriteByte(I2C_EEPROM)
I2C.WriteByte(Address)
'I2C.WriteByte(Address.Byte0)
I2C.Restart
I2C.WriteByte(I2C_EEPROM + 1)
Value = I2C.ReadByte
I2C.Acknowledge(I2C_NOT_ACKNOWLEDGE)
I2C.Stop
// output the result
USART.Write("Value = ", Value, 13, 10)
Code: Select all
Code: Select all