Quantcast
Channel: MCS Electronics Forum
Viewing all articles
Browse latest Browse all 20877

BASCOM-AVR : I2C slave and master in same chip..? : REPLY

$
0
0
I've tried this in all possible combinations, with or without twen, twie and twint twie 0/1 for master and so on. sub SetToSlave() twcr.twen = 0 twcr.twie = 0 twcr.twint = 1 Gosub _twi_init isMaster = 0 twcr.twen = 1 end sub sub SetToMaster() twcr.twen = 0 twcr.twie = 1 twcr.twint = 1 Gosub _i2c_init isMaster = 1 twcr.twen = 1 end sub My program starts with this (after all the basic stuff...): $lib "i2c_twi.lbx" twbr = 72 twsr = 0 'Config Twi = 100000 Config Sda = Portd.1 Config Scl = Portd.0 i2cinit const i2cAddress = &HA8 call SetToMaster() After that I send a few bytes on the I2C line and it works fine, see "beforeS.png" Then I load the slave driver, config it and set it back to Master: $lib "i2c_twi-slave.LBX" Config Twislave = &HA8 , BTR = 2 , BITRATE = 100000 , SAVE = save , GENCALL = no ', USERACK = on call SetToMaster() Now Master mode doesn't work and the I2C line looks like in AfterS.png [img] [/img] Any ideas?

Viewing all articles
Browse latest Browse all 20877

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>