Other Parts Discussed in Thread: MSP430FR5972, MSP430G2955
HI Jace
I want to return on my problem with I2Cbus on the microcontroller MSP430FR2476, as I wrote some times ago, there is a problem
and is impossible to enable this port on the UCB1.
I would like to precise that I using the I2CBus on the others item without any problem.
For all this Time, I had no time to finish this work but now need finish it, adn using the same controller onother equipment.
Really the problem is no the I2cbus but the inizialitation, I using the same routine from long time on different items withou any problem,
when I chang the Item only adapt the registers.
On the Msp430FR2476 when I set the initialization register is set the bit Busy and is impossible to use the I2cbus.
This on the UCB1 and UCB0 only for the I2cbus, because with SPI work properly. I have tested only UCB1 on SPI.
I have try all the following configuration ad when set bic.b #UCSWRST,UCB1CTL1 immediately is set the BUSYU bit into the UCB1STATW
and is impossible to use the I2Cbus.
FIRST OF ALL BSET_W, BCLR_W, BSET_B, BCLR_B are all macro
BSET_W .macro par0,par1
bisx.w #par0,par1
.endm
BCLR_W .macro par0,par1
bicx.w #par0,par1 ; *
.endm
BSET_B .macro par0,par1
bisx.b #par0,par1
.endm
BCLR_B .macro par0,par1
bicx.b #par0,par1 ; *
.endm
Configuration on your data sheet
UCBxCTL1 |= UCSWRST; // eUSCI_B in reset state
UCBxCTLW0 |= UCMODE_3; // I2C slave mode
UCBxI2COA0 = 0x0012; // own address is 12hex
P2SEL |= 0x03; // configure I2C pins (device specific)
UCBxCTL1 &= ^UCSWRST; // eUSCI_B in operational state
UCBxIE |= UCTXIE + UCRXIE; // enable TX&RX-interrupt
GIE; // general interrupt enable
I don't use the interrupt in this case and is Master mode
this configuration work Properly on the MSP430FR5972 and do not work on the MSP430FR2476
bis.w #UCSWRST,UCB0CTLW0
BSET_W ( UCMODE_3+UCMST+UCSYNC),UCB0CTLW0
MOV.W #I2SPEED_100KHZ,UCB0BRW
BCLR_W UCSWRST,UCB0CTLW0
this configuration work Properly on the MSP430G2955 and do not work on the MSP430FR2476
BSET_B UCSWRST,UCB0CTL1
BSET_B (UCMODE_3+UCMST+UCSYNC),UCB0CTL0
BSET_B UCMODE_3,P3SEL
MOV.B #I2SPEED_100KHZ_LSB,UCB0BR0
MOV.B #I2SPEED_100KHZ_MSB,UCB0BR1
BSET_B (UCSSEL0+UCSSEL1),UCB0CTL1
BCLR_B UCSWRST,UCB0CTL1
So I have made many possible configuration and following there are the example tested
all configuration when reset the bit UCSWRST,UCB0CTL1 immediately trigger the BUSY bit and is not possible to reset this bit more.
bis.b #(SCL+SDA),P4SEL0
bis.w #UCSWRST,UCB1CTLW0
bis.w #(UCMODE_3+UCMST+UCSYNC+UCSSEL0+UCSSEL1),UCB1CTLW0
mov.w #160,UCB1BRW
bic.w #UCSWRST,UCB1CTLW0
bis.w #UCSWRST,UCB1CTLW0
bis.w #(UCMODE_3+UCMST+UCSYNC+UCSSEL0+UCSSEL1),UCB1CTLW0
mov.w #160,UCB1BRW
bis.b #(SCL+SDA),P4SEL0
bis.w #UCASTP_2,UCB0CTLW1
bic.w #UCSWRST,UCB1CTLW0
in the following case when tryu to set the register with bit method and not with word method nothing ois changed
on the register
BSET_B UCSWRST,UCB1CTL1
BSET_B (UCMODE_3+UCMST+UCSYNC),UCB1CTL0
MOV.B #160,UCB1BR0
MOV.B #0,UCB1BR1
BSET_B (UCSSEL0+UCSSEL1),UCB1CTL1
BSET_B (SCL+SDA),P4SEL0
BCLR_B UCSWRST,UCB1CTL1
------------------------------
bis.b #UCSWRST,UCB1CTL1
bis.w #(UCMODE_3+UCMST+UCSYNC+UCSSEL0+UCSSEL1),UCB1CTLW0
mov.w #160,UCB1BRW
bis.b #(SCL+SDA),P4SEL0
bic.b #UCSWRST,UCB1CTL1
-----------
bis.b #UCSWRST,UCB1CTLW0
bis.w #(UCMODE_3+UCMST+UCSYNC+UCSSEL0+UCSSEL1),UCB1CTLW0
mov.w #160,UCB1BRW ;* PRESCALER LSB
bis.b #(SCL+SDA),P4SEL0
bic.b #UCSWRST,UCB1CTLW0
----------------------------
bis.b #UCSWRST,UCB1CTLW0
mov.w #(UCMODE_3+UCMST+UCSYNC+UCSSEL0+UCSSEL1+UCSWRST),UCB1CTLW0
mov.w #160,UCB1BRW
bis.b #(SCL+SDA),P4SEL0
bic.b #UCSWRST,UCB1CTLW0
----------------------------
bis.w #UCSWRST,UCB1CTLW0
mov.b #(UCMODE_3+UCMST+UCSYNC),UCB1CTL1
mov.w #160,UCB1BRW
bis.b #(SCL+SDA),P4SEL0
bic.w #UCSWRST,UCB1CTLW0
----------------------------
bis.w #UCSWRST,UCB1CTLW0
bis.w #(UCMODE_3+UCMST+UCSYNC+UCSSEL0+UCSSEL1+UCTXSTP+UCTXSTT),UCB1CTLW0
mov.w #160,UCB1BRW
bis.b #(SCL+SDA),P4SEL0
bic.w #UCSWRST,UCB1CTLW0
----------------------------
bis.w #UCSWRST,UCB1CTLW0
bis.w #(UCMODE_3+UCMST+UCSYNC+UCSSEL0+UCSSEL1+UCTXSTP+UCTXSTT),UCB1CTLW0
mov.w #160,UCB1BRW
bis.b #(SCL+SDA),P4SEL0
bis.w #UCTXSTP,UCB1CTLW0
bic.w #UCSWRST,UCB1CTLW0
----------------------------
bis.b #(SCL+SDA),P4SEL0
bis.w #UCSWRST,UCB1CTLW0
bis.w #(UCMODE_3+UCMST+UCSYNC+UCSSEL0+UCSSEL1+UCTXSTP+UCTXSTT),UCB1CTLW0
mov.w #160,UCB1BRW
bis.w #UCTXSTP,UCB1CTLW0
bic.w #UCSWRST,UCB1CTLW0
---------------------------------
bis.w #UCSWRST,UCB1CTLW0
bis.w #(UCMODE_3+UCMST+UCSYNC+UCSSEL0+UCSSEL1+UCTXSTP+UCTXSTT),UCB1CTLW0
mov.w #160,UCB1BRW
bis.w #UCTXSTP,UCB1CTLW0
bic.w #UCSWRST,UCB1CTLW0
bis.b #(SCL+SDA),P4SEL0