Sign in

username:

password:



Not a member?

Search msp430



Search tips

Subscribe to msp430



Ads

Discussion Groups

Discussion Groups | MSP430 | I2C-bus stays "busy" (USCI)

The purpose of this group is to foster exchange of information on the Texas Instruments MSP430 family of microcontrollers and related tools. Everyone welcome, all levels of familiarity/expertise.

I2C-bus stays "busy" (USCI) - andersryl - Sep 18 10:25:22 2008

Hi all,

I'm having trouble getting the USCIB0 module to work as an I2C master in
my 2619 device.
I have followed the code for application note "slaa382" (I have tried
both with and without DMA) but I can't get any I2C-traffic on the bus.

When using an oscilloscope I see that the SCL line stays high and SDA
line stays low after I reset the board.

The configuration code for the USCIB0 looks like:

void I2C_Init (void)
{
UCB0CTL1 = UCSWRST; // Hold USCIB0 in reset

UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC; // I2C Master, synchronous mode
UCB0CTL1 = UCSSEL_1 + UCSWRST; // Use ACLK
UCB0BR0 = SCL_FREQ_DIV & 0xFF; // Set SCL-freq (150 kHz)
UCB0BR1 = (SCL_FREQ_DIV >> 8); //

P3SEL |= 0x06; // Configure pins

UCB0CTL1 &= ~UCSWRST; // Clear UCSWRST

UCB0I2CIE = UCNACKIE; // Enable I2C state change interrupts
IE2 |= UCB0TXIE; // Enable I2C Tx interrupt
}

Before calling the init function I call __enable_interrupt();

The function to send data looks like:

void I2C_send (uint8_t *data, uint8_t byteCount)
{
volatile uint16_t ii;
while (UCB0STAT & UCBBUSY) { // Wait for I2C-bus to be free
for (ii=0;ii<60000;ii++);
RED_LED_TOGGLE();
}

UCB0I2CSA = 0x0C; // Set slave address

I2C_TransmitData = data;
I2C_TxByteCtr = byteCount;

UCB0CTL1 |= UCTR + UCTXSTT; // I2C Tx, start condition
}

The send function gets stuck in the while-loop.

The ISR looks like:

#pragma vector = USCIAB0TX_VECTOR
__interrupt void USCIAB0TX_ISR(void)
{
if (I2C_TxByteCtr == 0){
UCB0CTL1 |= UCTXSTP; // I2C stop condition
IFG2 &= ~UCB0TXIFG; // Clear USCI_B0 TX int flag
}
else {
UCB0TXBUF = *I2C_TransmitData;
I2C_TransmitData++;
I2C_TxByteCtr--;
}
}

Anyone who sees where I go wrong?

Thanks in advance,
Anders

[Non-text portions of this message have been removed]
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )


Re: I2C-bus stays "busy" (USCI) - owaiscareer - Nov 17 20:58:53 2008

Hello,
I'm in the same exact situation. Did you resolve your issue? If you
did, do you mind sharing?
Thanks!

--- In m...@yahoogroups.com, "andersryl" wrote:
>
> Hi all,
>
> I'm having trouble getting the USCIB0 module to work as an I2C master in
> my 2619 device.
> I have followed the code for application note "slaa382" (I have tried
> both with and without DMA) but I can't get any I2C-traffic on the bus.
>
> When using an oscilloscope I see that the SCL line stays high and SDA
> line stays low after I reset the board.
>
> The configuration code for the USCIB0 looks like:
>
> void I2C_Init (void)
> {
> UCB0CTL1 = UCSWRST; // Hold USCIB0 in reset
>
> UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC; // I2C Master, synchronous
mode
> UCB0CTL1 = UCSSEL_1 + UCSWRST; // Use ACLK
> UCB0BR0 = SCL_FREQ_DIV & 0xFF; // Set SCL-freq (150 kHz)
> UCB0BR1 = (SCL_FREQ_DIV >> 8); //
>
> P3SEL |= 0x06; // Configure pins
>
> UCB0CTL1 &= ~UCSWRST; // Clear UCSWRST
>
> UCB0I2CIE = UCNACKIE; // Enable I2C state change interrupts
> IE2 |= UCB0TXIE; // Enable I2C Tx interrupt
> }
>
> Before calling the init function I call __enable_interrupt();
>
> The function to send data looks like:
>
> void I2C_send (uint8_t *data, uint8_t byteCount)
> {
> volatile uint16_t ii;
> while (UCB0STAT & UCBBUSY) { // Wait for I2C-bus to be free
> for (ii=0;ii<60000;ii++);
> RED_LED_TOGGLE();
> }
>
> UCB0I2CSA = 0x0C; // Set slave address
>
> I2C_TransmitData = data;
> I2C_TxByteCtr = byteCount;
>
> UCB0CTL1 |= UCTR + UCTXSTT; // I2C Tx, start condition
> }
>
> The send function gets stuck in the while-loop.
>
> The ISR looks like:
>
> #pragma vector = USCIAB0TX_VECTOR
> __interrupt void USCIAB0TX_ISR(void)
> {
> if (I2C_TxByteCtr == 0){
> UCB0CTL1 |= UCTXSTP; // I2C stop condition
> IFG2 &= ~UCB0TXIFG; // Clear USCI_B0 TX int flag
> }
> else {
> UCB0TXBUF = *I2C_TransmitData;
> I2C_TransmitData++;
> I2C_TxByteCtr--;
> }
> }
>
> Anyone who sees where I go wrong?
>
> Thanks in advance,
> Anders
>
> [Non-text portions of this message have been removed]
>

------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )