Part Number: MSP430FR2633
Other Parts Discussed in Thread: ADS122C04
I want to interface two external peripherals on same MSP430FR2633 Micro controller.
One device is on UART and another one is on I2C.
Firstly, I have configured my UART on 8 MHz clock with 9600 baud rate and my UART device working up to date properly on same frequency with baud rate.
The problem with my code is I2C device not responding on same frequency with define prescaler value.
My I2C code is working with 1MHz clock. And I want to run my I2C on 8MHz clock (SMCLK).
So, how can I run on same MSP430FR2633 with this I2C interface on same 8MHz clock.
Please do needful.
Here is my code:
#include <msp430fr2633.h>
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
PM5CTL0 &= ~LOCKLPM5;
//8MHz Clock Configuration
__bis_SR_register(SCG0); // disable FLL
CSCTL3 |= SELREF__REFOCLK; // Set REFO as FLL reference source
CSCTL0 = 0; // clear DCO and MOD registers
CSCTL1 &= ~(DCORSEL_7); // Clear DCO frequency select bits first
CSCTL1 |= DCORSEL_3; // Set DCO = 8MHz
CSCTL2 = FLLD_0 + 243; // DCODIV = 8MHz
__delay_cycles(3);
__bic_SR_register(SCG0); // enable FLL
while(CSCTL7 & (FLLUNLOCK0 | FLLUNLOCK1)); // Poll until FLL is locked
CSCTL4 = SELMS__DCOCLKDIV | SELA__REFOCLK; // set default REFO(~32768Hz) as ACLK source, ACLK = 32768Hz
// default DCODIV as MCLK and SMCLK source
// Configure Pins for I2C
P1SEL0 |= BIT2 | BIT3; // I2C pins
//I2C Configuration for 1 MHz clock
UCB0CTLW0 |= UCSWRST; // put eUSCI_B in reset state
UCB0CTLW0 |= UCMODE_3 | UCMST | UCSYNC; // I2C master mode, SMCLK, USC SYNC Mode
UCB0BRW = 0x8; // Set Bit rate 100 kHz
UCB0I2CSA = 0x40; // ADC122C04 slave Device address
UCB0CTLW0 &= ~UCSWRST; // Software Reset Disable
UCB0IE |= UCTXIE0 | UCNACKIE; // Tx Interrupt Enable, Not-acknowlege Interrupt Enable for if Negative Ack then Repeat Start
// Configure UART0
P1SEL0 |= BIT4 | BIT5; // Set P1.4 and P1.5 as UART0 Mod
UCA0CTLW0 |= UCSWRST; // Software Reset Enable
UCA0CTLW0 |= UCSSEL_3; // Set ACLK as BRCLK
UCA0BR0 = 52; // 8000000/16/9600
UCA0BR1 = 0x00;
UCA0MCTLW = 0x4900 | UCOS16 | UCBRF_10; // 9600 Baud Rate Setting from the User Guide Table
}



