Hi guys,
I am trying to transmitt a data to slave address and trying to read it back. I can see the value in AC1 when i step through but not when I run the program and set a break point
#define true 1
#include "msp430f2252.h"
volatile unsigned char receive = 0;
volatile unsigned char ready = 0;
volatile short ac1 = 0;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
BCSCTL1 = CALBC1_1MHZ;
DCOCTL = CALDCO_1MHZ;
// Initialise i2c
P3SEL |= 0x06; // Assign I2C pins to USCI_B0
UCB0CTL1 |= UCSWRST; // Enable SW reset
UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC; // I2C Master, synchronous mode
UCB0CTL1 = UCSSEL_2 + UCSWRST; // Use SMCLK, keep SW reset
UCB0BR0 = 6; // fSCL = SMCLK/12 = ~100kHz
UCB0BR1 = 0;
IE2 |= UCB0RXIE; // Enable RX interrupt
__delay_cycles(5);
__bis_SR_register(CPUOFF + GIE); // Enter LPM0 w/ interrupts
// Set the slave address
UCB0I2CSA = 0x77; //01110111
UCB0CTL1 &= ~UCSWRST; // software reset disable.
// Start transmit condition
UCB0CTL1 |= UCTR; // Enable Transmissoin mode
UCB0CTL1 |= UCTXSTT; // generating start condition by setting UCTXSTT
// Reading the calibration data
while(!(IFG2 & UCB0TXIFG)); // USCI_B0 RX buffer ready?
UCB0TXBUF = 0xAC; // Transmit address to buffer
// Send restart condition
UCB0CTL1 &= ~UCTR; //Disable Transmission Mode
UCB0CTL1 |= UCTXSTT; // gererate start condition
// Should receive two bytes from the slave
//while(!(IFG2 & UCB0RXIFG));
ac1 = (short) (UCB0RXBUF << 8); // 16-bit
//UCB0CTL1 |= UCTXSTP;
//while(!(IFG2 & UCB0RXIFG));
ac1 = ac1 | UCB0RXBUF;
// Respond with a NACK after receiving second byte
UCB0CTL1 |= UCTXSTP; // generate stop condition after the next acknowledge from the slave
I have a break Point here. I shout get ac1 value in my watch window, when I run my program but I do not get anything. Can anyone suggest why I am unable to do that. If this is possible through interrupts please advise. Thanks.
I am using Code Composer studio. Any help would be appreciatable. Thanks.