Other Parts Discussed in Thread: MSPWARE,
Hello,
I'm currently trying to get examle from MSPWare working on MSP430FR6047 platform. I want to use USCI_B1_BASE instead of USCI_B0_BASE, so I changed example so it should use EUSCI_B1_BASE, but when I check data lines with logic analyzer, they are in logic 1 without any data. I tried also other examples and behavior is same.
Modified code is bellow.
Thank you,
Tadeas
/* --COPYRIGHT--,BSD * --/COPYRIGHT--*/ #include "driverlib.h" //***************************************************************************** // //! i2c_master_rx_multi_int //! //! This example shows how to configure the I2C module as a master for //! multi-byte reception with teh help of interrupts. The address of the slave module //! that the master communicating with also set in this example. This example uses //! the interrupt driven mode to receive data. //! //! This example uses the following peripherals and I/O signals. You must //! review these and change as needed for your own board: //! - I2C peripheral //! - GPIO Port peripheral (for I2C pins) //! - SCL2 //! - SDA //! //! This example uses the following interrupt handlers. To use this example //! in your own application you must add these interrupt handlers to your //! vector table. //! - USCI_B0_VECTOR //! // //***************************************************************************** #define SLAVE_ADDRESS 0x10 //***************************************************************************** // //Specify Expected Receive data count. // //***************************************************************************** #define RXCOUNT 0x05 //****************************************************************************** // MSP430FR59xx Demo - USCI_B0 I2C Master RX multiple bytes from MSP430 Slave //****************************************************************************** uint8_t RXData; void main (void) { WDT_A_hold(WDT_A_BASE); //Set DCO frequency to 1MHz CS_setDCOFreq(CS_DCORSEL_0,CS_DCOFSEL_0); //Set ACLK = VLO with frequency divider of 1 CS_initClockSignal(CS_ACLK,CS_VLOCLK_SELECT,CS_CLOCK_DIVIDER_1); //Set SMCLK = DCO with frequency divider of 1 CS_initClockSignal(CS_SMCLK,CS_DCOCLK_SELECT,CS_CLOCK_DIVIDER_1); //Set MCLK = DCO with frequency divider of 1 CS_initClockSignal(CS_MCLK,CS_DCOCLK_SELECT,CS_CLOCK_DIVIDER_1); // Configure Pins for I2C //Set P1.6 and P1.7 as Secondary Module Function Input. /* * Select Port 8 * Set Pin 5, 6 to input Secondary Module Function, (UCB1SDA, UCB1SCL). */ GPIO_setAsPeripheralModuleFunctionInputPin( GPIO_PORT_P8, GPIO_PIN5 + GPIO_PIN6, GPIO_SECONDARY_MODULE_FUNCTION ); //Set P1.0 as an output pin. /* * Select Port 1 * Set Pin 0 as output */ GPIO_setAsOutputPin( GPIO_PORT_P1, GPIO_PIN0 ); /* * Disable the GPIO power-on default high-impedance mode to activate * previously configured port settings */ PMM_unlockLPM5(); EUSCI_B_I2C_initMasterParam param = {0}; param.selectClockSource = EUSCI_B_I2C_CLOCKSOURCE_SMCLK; param.i2cClk = CS_getSMCLK(); param.dataRate = EUSCI_B_I2C_SET_DATA_RATE_400KBPS; param.byteCounterThreshold = RXCOUNT; param.autoSTOPGeneration = EUSCI_B_I2C_SEND_STOP_AUTOMATICALLY_ON_BYTECOUNT_THRESHOLD; EUSCI_B_I2C_initMaster(EUSCI_B1_BASE, ¶m); //Specify slave address EUSCI_B_I2C_setSlaveAddress(EUSCI_B1_BASE, SLAVE_ADDRESS ); //Set Master in receive mode EUSCI_B_I2C_setMode(EUSCI_B1_BASE, EUSCI_B_I2C_RECEIVE_MODE ); //Enable I2C Module to start operations EUSCI_B_I2C_enable(EUSCI_B1_BASE); EUSCI_B_I2C_clearInterrupt(EUSCI_B1_BASE, EUSCI_B_I2C_RECEIVE_INTERRUPT1 + EUSCI_B_I2C_BYTE_COUNTER_INTERRUPT + EUSCI_B_I2C_NAK_INTERRUPT ); //Enable master Receive interrupt EUSCI_B_I2C_enableInterrupt(EUSCI_B1_BASE, EUSCI_B_I2C_RECEIVE_INTERRUPT1 + EUSCI_B_I2C_BYTE_COUNTER_INTERRUPT + EUSCI_B_I2C_NAK_INTERRUPT ); while (1) { __delay_cycles(2000); while (EUSCI_B_I2C_SENDING_STOP == EUSCI_B_I2C_masterIsStopSent(EUSCI_B1_BASE)); EUSCI_B_I2C_masterReceiveStart(EUSCI_B1_BASE); // Enter LPM0 w/ interrupt __bis_SR_register(CPUOFF+GIE); } } #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) #pragma vector=USCI_B1_VECTOR __interrupt #elif defined(__GNUC__) __attribute__((interrupt(USCI_B1_VECTOR))) #endif void USCIB1_ISR(void) { static uint8_t count = 0; switch(__even_in_range(UCB1IV, USCI_I2C_UCBIT9IFG)) { case USCI_NONE: // No interrupts break; break; case USCI_I2C_UCALIFG: // Arbitration lost break; case USCI_I2C_UCNACKIFG: // NAK received (master only) EUSCI_B_I2C_masterReceiveStart(EUSCI_B1_BASE); break; case USCI_I2C_UCSTTIFG: // START condition detected with own address (slave mode only) break; case USCI_I2C_UCSTPIFG: // STOP condition detected (master & slave mode) break; case USCI_I2C_UCRXIFG3: // RXIFG3 break; case USCI_I2C_UCTXIFG3: // TXIFG3 break; case USCI_I2C_UCRXIFG2: // RXIFG2 break; case USCI_I2C_UCTXIFG2: // TXIFG2 break; case USCI_I2C_UCRXIFG1: // RXIFG1 break; case USCI_I2C_UCTXIFG1: // TXIFG1 break; case USCI_I2C_UCRXIFG0: // RXIFG0 // Get RX data RXData = EUSCI_B_I2C_masterReceiveSingle( EUSCI_B1_BASE ); if (++count >= RXCOUNT) { count = 0; __bic_SR_register_on_exit(CPUOFF); // Exit LPM0 } break; // Vector 24: RXIFG0 break; case USCI_I2C_UCTXIFG0: // TXIFG0 break; case USCI_I2C_UCBCNTIFG: // Byte count limit reached (UCBxTBCNT) GPIO_toggleOutputOnPin( GPIO_PORT_P1, GPIO_PIN0 ); break; case USCI_I2C_UCCLTOIFG: // Clock low timeout - clock held low too long break; case USCI_I2C_UCBIT9IFG: // Generated on 9th bit of a transmit (for debugging) break; default: break; } }