Other Parts Discussed in Thread: MSP430FR2355, HDC2080, HDC2022,
I am trying to port the sample code in /msp430fr2355_demo_with_hdc2080/main.c to our hardware (FR2353, HDC2022). I'm using USCI_B1.
The I2C peripheral is not generating an interrupt (never hits the breakpoint I set on the first statement in the ISR).
First of all, am I using the correct keyword in the statement below:
#pragma vector = USCI_B1_VECTOR
How about this?
#pragma vector = EUSCI_B1_VECTOR
Do both point to the same interrupt vector? Both Build with no errors.
Here are some of my code snippets that were modified to match my hardware.
void initGPIO() { ......... skipped lines // I2C pins (P4.7 is SCL, P4.6 is SDA) P4SEL0 |= BIT6 | BIT7; P4SEL1 &= ~(BIT6 | BIT7); .......skipped lines } void initI2C() { UCB1CTLW0 = UCSWRST; // Enable SW reset UCB1CTLW0 |= UCMODE_3 | UCMST | UCSSEL__SMCLK | UCSYNC; // I2C master mode, SMCLK UCB1BRW = 160; // fSCL = SMCLK/160 = ~100kHz UCB1I2CSA = SLAVE_ADDR; // Slave Address UCB1CTLW0 &= ~UCSWRST; // Clear SW reset, resume operation UCB1IE |= UCNACKIE; } //****************************************************************************** // I2C Interrupt *************************************************************** //****************************************************************************** #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) #pragma vector = USCI_B1_VECTOR __interrupt void USCI_B1_ISR(void) #elif defined(__GNUC__) void __attribute__ ((interrupt(USCI_B1_VECTOR))) USCI_B1_ISR (void) #else #error Compiler not supported! #endif { //Must read from UCB1RXBUF uint8_t rx_val = 0; switch(__even_in_range(UCB1IV, USCI_I2C_UCBIT9IFG)) <<<<<<<<<<<Breakpoint set here..... { ....... ...... } I2C_Mode I2C_Master_WriteReg(uint8_t dev_addr, uint8_t reg_addr, uint8_t *reg_data, uint8_t count) { /* Initialize state machine */ MasterMode = TX_REG_ADDRESS_MODE; TransmitRegAddr = reg_addr; //Copy register data to TransmitBuffer CopyArray(reg_data, TransmitBuffer, count); TXByteCtr = count; RXByteCtr = 0; ReceiveIndex = 0; TransmitIndex = 0; /* Initialize slave address and interrupts */ UCB1I2CSA = dev_addr; UCB1IFG &= ~(UCTXIFG + UCRXIFG); // Clear any pending interrupts UCB1IE &= ~UCRXIE; // Disable RX interrupt UCB1IE |= UCTXIE; // Enable TX interrupt UCB1CTLW0 |= UCTR + UCTXSTT; // I2C TX, start condition __bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupts <<<<<<<<<<<< HANGS HERE............... return MasterMode; }When I run the program, it hangs on the line:
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupts
The breakpoint is not hit.
This is the first attempt to use I2C to talk to the HDC2022).