Quantcast
Channel: MSP low-power microcontroller forum - Recent Threads
Viewing all articles
Browse latest Browse all 21936

Linux/MSP430F5529: MSP430F5529 I2C changed clock I2C blocked

$
0
0

Part Number:MSP430F5529

Tool/software: Linux

Hello and happy new year,

I changed the clock on my MSP430F5529 from a 20MHz to a 24MHz to be able to used USB-BSL and have high frequency clock. And since that, i can't seem to be able to send data via I2C.  I have tried to have the I2C frequency to 12MHz and 6MHz with SMCLK and ACLK but it doesn't seem to work, will i precedently had I2C at 10MHz with SMCLK on my 20MHz clock.

It doesn't seem to be an electrical issues since when i revert to a 20MHz clock it work.

So i'm asking for your help and your knowledge, please Help:

I use the TI library, my code:

clock.h/c:

#define CLOCK_RATE_MCLK        24000000
#define CLOCK_MS_MCLK        20000
#define CLOCK_RATE_SMCLK    12000000
#define CLOCK_RATE_ACLK        6000000

    GPIO_setAsPeripheralModuleFunctionInputPin(XT2_PIN_1);
    GPIO_setAsPeripheralModuleFunctionInputPin(XT2_PIN_2);
    
    //set speed clock acordingly to the speed authorized in the datasheet in the UCS chapter
    UCS_setExternalClockSource(32768,CLOCK_RATE_MCLK); // XT2=24MHz NO XT1

    // Set Vcore to accomodate for max. allowed system speed
    PMM_setVCore(PMM_CORE_LEVEL_3);

    //Init crystal (not meth)
    UCS_turnOnXT2(UCS_XT2_DRIVE_4MHZ_8MHZ);//hight frequency
    UCS_turnOffXT1();

    // Use the crystals to set the clocks; the slower the clock the less power consuption it take
    UCS_initClockSignal(UCS_MCLK,UCS_XT2CLK_SELECT,UCS_CLOCK_DIVIDER_1); // clock is at 24MHz
    UCS_initClockSignal(UCS_SMCLK,UCS_XT2CLK_SELECT,UCS_CLOCK_DIVIDER_2);// clock at 12MHz
    UCS_initClockSignal(UCS_ACLK,UCS_XT2CLK_SELECT,UCS_CLOCK_DIVIDER_4);//clock at 6MHz

I2C init:

GPIO_setAsPeripheralModuleFunctionOutputPin(PRESSURE_SENSOR_B1);

USCI_B_I2C_initMasterParam param;
param.selectClockSource = USCI_B_I2C_CLOCKSOURCE_ACLK;
param.i2cClk = CLOCK_RATE_ACLK;//6MHz
param.dataRate = USCI_B_I2C_SET_DATA_RATE_100KBPS;

USCI_B_I2C_initMaster(USCI_B1_BASE, &param);

USCI_B_I2C_setSlaveAddress(USCI_B1_BASE, add);

USCI_B_I2C_setMode(USCI_B1_BASE, USCI_B_I2C_TRANSMIT_MODE);

USCI_B_I2C_disableInterrupt(USCI_B1_BASE, USCI_B_I2C_TRANSMIT_INTERRUPT); USCI_B_I2C_disableInterrupt(USCI_B1_BASE, USCI_B_I2C_RECEIVE_INTERRUPT);

I2C send:

USCI_B_I2C_masterSendSingleByte(USCI_B1_BASE, data);
ms_delay(1);
USCI_B_I2C_clearInterrupt(USCI_B1_BASE, USCI_B_I2C_TRANSMIT_INTERRUPT);
USCI_B_I2C_clearInterrupt(USCI_B1_BASE, USCI_B_I2C_STOP_INTERRUPT);

Driver I2C FROM TI:

void USCI_B_I2C_masterSendSingleByte(uint16_t baseAddress,
                                     uint8_t txData)
{
    //Store current TXIE status
    uint8_t txieStatus = HWREG8(baseAddress + OFS_UCBxIE) & UCTXIE;

    //Disable transmit interrupt enable
    HWREG8(baseAddress + OFS_UCBxIE) &= ~(UCTXIE);

    //Send start condition.
    HWREG8(baseAddress + OFS_UCBxCTL1) |= UCTR + UCTXSTT;

    //Poll for transmit interrupt flag.
    while(!(HWREG8(baseAddress + OFS_UCBxIFG) & UCTXIFG))
    {
        ;
    }

    //Send single byte data.
    HWREG8(baseAddress + OFS_UCBxTXBUF) = txData;

    //Poll for transmit interrupt flag.
    while(!(HWREG8(baseAddress + OFS_UCBxIFG) & UCTXIFG))
    {
        ;//IS BLOOCKED HERE
    }

    //Send stop condition.
    HWREG8(baseAddress + OFS_UCBxCTL1) |= UCTXSTP;

    //Clear transmit interrupt flag before enabling interrupt again
    HWREG8(baseAddress + OFS_UCBxIFG) &= ~(UCTXIFG);

    //Reinstate transmit interrupt enable
    HWREG8(baseAddress + OFS_UCBxIE) |= txieStatus;
}

thanks,

Aurelia


Viewing all articles
Browse latest Browse all 21936

Trending Articles



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