Jump to content

Search the Community

Showing results for tags 'usci'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • News
    • Announcements
    • Suggestions
    • New users say Hi!
  • Spotlight!
    • Sponsor Spotlight
    • Sponsor Giveaways
  • Energia
    • Energia - MSP
    • Energia - TivaC/CC3XXX
    • Energia - C2000
    • Energia Libraries
  • MSP Technical Forums
    • General
    • Compilers and IDEs
    • Development Kits
    • Programmers and Debuggers
    • Code vault
    • Projects
    • Booster Packs
    • Energia
  • Tiva-C, Hercules, CCXXXX ARM Technical Forums
    • General
    • SensorTag
    • Tiva-C, Hercules, CC3XXX Launchpad Booster Packs
    • Code Vault
    • Projects
    • Compilers and IDEs
    • Development Kits and Custom Boards
  • Beagle ARM Cortex A8 Technical Forums
    • General
    • Code Snippets and Scripts
    • Cases, Capes and Plugin Boards
    • Projects
  • General Electronics Forum
    • General Electronics
    • Other Microcontrollers
  • Connect
    • Embedded Systems/Test Equipment Deals
    • Buy, Trade and Sell
    • The 43oh Store
    • Community Projects
    • Fireside Chat
  • C2000 Technical Forums
    • General
    • Development Kits
    • Code Vault
    • Projects
    • BoosterPacks

Calendars

There are no results to display.


Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Location


Interests


Sparkfun


Github

Found 6 results

  1. I was trying to port a sketch that used the Serial port with non standard UART parity and character length to Energia. I noticed that the UART port isn't setup to handle anything except 8-N-1. While the code below can't do all the combinations that are available to the atmega, it can do 7/8 bit, even/odd parity and 1/2 stop bits. I created a patch that will at least fix it for the chip I am using (msp430g2553). It will need some work for other chips. Apply the attached patch to the source of the latest Energia source tree. (as of 11/11/2015) -rick (See new optional second parameter https://www.arduino.cc/en/Serial/Begin ) parity.patch
  2. Hello! I am compiling the following code through CCS 6.1.3, it is an imported sketch first then I add some thing else for it. But it seems It stuck in the setup function because it goes to LPM4 when it tries to use any USCI related function( For example: Wire.begin(),write to ()). Can some one help me with it? Thanks. The attach file is the ino file from energia 17 and the following is the Code? The uc is MSP430F5529, and it is trying to use I2C to communicate with ADXL345, UART to communicate with ESP8266. The reset is ADC stuff. And we have a button to do some control. Each of these parts works fine by themselves alone. This is why I can not understand. #include <Wire.h> #include <msp430f5529.h> #define DEBUG true //Prints AT responses to serial terminal, set to False if you do not want to print void ADC_SETUP( void ) ; void TIMER_A2_SETUP( void ) ; void EXTERNAL_SETUP( void ) ; void READ_ACCELERATION( void ) ; void READ_ADC( void ) ; //Global Variables char flag = 0x00 ; //Declares 8-bit flag character and initializes to 0. int btn_cnt = 0 ; //int png_cnt = 0 ; int tmr_cnt = 0 ; int accel_data[3] = { 0 , 0 , 0 } ; double temp = 0 ; int snd = 0 ; int trash = 0 ; #define DEVICE (0x53) // Device address as specified in data sheet byte _buff[6]; char POWER_CTL = 0x2D; //Power Control Register char DATA_FORMAT = 0x31; char DATAX0 = 0x32; //X-Axis Data 0 char DATAX1 = 0x33; //X-Axis Data 1 char DATAY0 = 0x34; //Y-Axis Data 0 char DATAY1 = 0x35; //Y-Axis Data 1 char DATAZ0 = 0x36; //Z-Axis Data 0 char DATAZ1 = 0x37; //Z-Axis Data 1 String wifiSSID= "suddenlink.net-D0B3"; //Set this to your WiFi SSID String wifiKey = "G2PBW489C600863"; //Set this to your WiFi password //String apiKey = "L0LX8JG2D8YETKFB"; //API key from thing speak, used to post data String apiKey = "7N3L4F8YP90A6S82"; //API key from thing speak, used to post data void setup() { __bic_SR_register( CPUOFF ) ; WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer //Setup peripherals ADC_SETUP() ; EXTERNAL_SETUP() ; TIMER_A2_SETUP() ; //pinMode(P4_7, OUTPUT) ; P2SEL &= ~BIT5 ; P2DIR |= BIT5 ; Wire.begin(); //I2C __delay_cycles(100); Serial.begin(115200); //UART __delay_cycles(100); //Put the ADXL345 into +/- 4G range by writing the value 0x01 to the DATA_FORMAT register. P2SEL &= ~BIT4 ; P2DIR |= BIT4 ; P2OUT &= ~BIT4 ; __delay_cycles(100); P2OUT |= BIT4 ; __delay_cycles(100); //digitalWrite(P4_7, LOW); P2OUT &= ~BIT5 ; __delay_cycles(100); //digitalWrite(P4_7, HIGH); P2OUT |= BIT5 ; __delay_cycles(100); writeTo(DATA_FORMAT, 0x01); __delay_cycles(100); __bic_SR_register( CPUOFF ) ; __delay_cycles(100); //Put the ADXL345 into Measurement Mode by writing 0x08 to the POWER_CTL register. writeTo(POWER_CTL, 0x08); __delay_cycles(100); __bic_SR_register( CPUOFF ) ; sendData("AT+RST\r\n",200,DEBUG); // reset module __delay_cycles(100); sendData("AT+CWMODE=3\r\n",100,DEBUG); //configure to access AP String cnnct = ("AT+CWJAP=\"" + wifiSSID + "\",\"" + wifiKey +"\"\r\n"); //Set up string to connect to wifi String response = sendData(cnnct,20000,DEBUG); //Connect to wifi using credentials provided while (response.indexOf("FAIL") != -1) { //If connection failed, try again response = sendData(cnnct,20000,DEBUG); } __bis_SR_register( GIE ); // interrupts enabled } void loop() { __bic_SR_register( CPUOFF ) ; //Read acceleration data each loop READ_ACCELERATION () ; READ_ADC() ; //__bis_SR_register( GIE ); // interrupts enabled //ADC12CTL0 |= ADC12SC ; //Flag Handlers if( ( flag>>0 )&1 ) //Flag = 0bxxx1 {//Temp flag handler temp = .8059 * ( ( temp - 2637 ) / ( -13.6 ) ) ; // LSB -> deg C thingSpeak( temp , 0 , 0 ) ; //Reset flag flag &= ~BIT0 ; } if( ( flag>>1 )&1 ) //Flag = 0bxx1x {//Mic flag handler thingSpeak( snd , 0 , 0 ) ; //Reset flag flag &= ~BIT1 ; } if( ( flag>>2 )&1 ) //Flag = 0bx1xx {//External button flag handler //Send button pushed data thingSpeak( 0 , 0 , 0 ) ; //Reset flag flag &= ~BIT2 ; } if( ( flag>>3 )&1 ) //Flag = 0b1xxx {//External accelerometer flag handler thingSpeak( accel_data[0] , accel_data[1] , accel_data[2] ) ; //Reset flag flag &= ~BIT3 ; } if( ( flag>>4 )&1 ) //Flag = 0b1xxxx {//Ping flag handler thingSpeak( 0 , 0 , 0 ) ; //Reset flag flag &= ~BIT4 ; } } void thingSpeak( int datax , int datay , int dataz ) {// datax is used as main data send. If not used for accelerometer, datay and dataz are not used. char flg = flag ; //Set flg to ensure flag doesn't change. String dataWrite ; sendData( "AT+CIPSTART=\"TCP\",\"184.106.153.149\",80\r\n" , 50 , DEBUG ) ; // turn on server on port 80 //Field 1: x data //Field 2: y data //Field 3: z data //Field 4: temp data //Field 5: microphone event //Field 6: ping data and reset button switch( flg ){ case 1: // Temp data dataWrite = "GET /update?api_key=" + apiKey + "&field4=" + String(datax) + "\r\n" ; break ; case 2: // Microphone event dataWrite = "GET /update?api_key=" + apiKey + "&field5=" + String(datax) + "\r\n" ; break ; case 4: // Button pushed data dataWrite = "GET /update?api_key=" + apiKey + "&field6=" + String(1) + "\r\n" ; break ; case 8: // Accelerometer data dataWrite = "GET /update?api_key=" + apiKey + "&field1=" + String(datax) + "&field2=" + String(datay) + "&field3=" + String(dataz) + "\r\n" ; break ; case 16: // Ping case dataWrite = "GET /update?api_key=" + apiKey + "&field6=" + String(0) + "\r\n" ; default: ; } String cmd = "AT+CIPSEND=" ; int length = dataWrite.length() ; cmd += length; cmd += "\r\n"; sendData(cmd,50,DEBUG); //Set up TCP connection sendData(dataWrite,10,DEBUG); //Send data to thing speak //long int time = millis(); //while((time+500)>millis()){} //delay for 5 seconds before sending data __delay_cycles(50) ; } String sendData(String command, const int timeout, boolean debug) { String output = ""; Serial.print(command); // send the read character to the Serial1 //long int time = millis(); long int time = 0 ; //while( (time+timeout) > millis())//wait for a response until timeout is up while( time++ < timeout ) { while(Serial.available()) {// The esp has data so display its output to the serial window char c = Serial.read(); // read the next character. output+=c; } if ((output.indexOf("FAIL") != -1)||(output.indexOf("OK")!=-1)){ //if response received break from the timeout loop break; } __delay_cycles(10) ; } return output; } void writeTo(byte address, byte val) { Wire.beginTransmission(DEVICE); // start transmission to device Wire.write(address); // send register address Wire.write(val); // send value to write Wire.endTransmission(); // end transmission } // Reads num bytes starting from address register on device in to _buff array void readFrom(byte address, int num, byte _buff[]) { Wire.beginTransmission(DEVICE); // start transmission to device Wire.write(address); // sends address to read from Wire.endTransmission(); // end transmission Wire.beginTransmission(DEVICE); // start transmission to device Wire.requestFrom(DEVICE, num); // request 6 bytes from device int i = 0; while(Wire.available()) // device may send less than requested (abnormal) { _buff = Wire.read(); // receive a byte i++; } Wire.endTransmission(); // end transmission } void setRegisterBit(byte regAdress, int bitPos, bool state) { byte _b; readFrom(regAdress, 1, &_ ; if (state) { _b |= (1 << bitPos); // forces nth bit of _b to be 1. all other bits left alone. } else { _b &= ~(1 << bitPos); // forces nth bit of _b to be 0. all other bits left alone. } writeTo(regAdress, _ ; } void ADC_SETUP( void ) {//Multiple conversions ADC12CTL0 = ADC12ON + ADC12MSC + ADC12SHT0_8 ; // Turn on ADC12, extend sampling time to avoid overflow of results ADC12CTL1 = ADC12SHP + ADC12CONSEQ_3 ; // Use sampling timer, repeated sequence ADC12MCTL0 = ADC12INCH_4 ; // ref+=AVcc, channel = A4 ADC12MCTL1 = ADC12INCH_12 + ADC12EOS ; // ref+=AVcc, channel = A12, end seq. //ADC12IE = ADC12IE0 + ADC12IE1 ; // Enable ADC12IFG.3 ADC12CTL0 |= ADC12ENC; // Enable conversions return ; } void TIMER_A2_SETUP( void ) {//Setup registers for Timer_A1 TA2CCR0 = 0x11C1 ; // Count up to 1 sec TA2CCTL0 = CCIE ; TA2CTL = TASSEL_1 + MC_1 + TACLR + ID_3 ; return ; } void EXTERNAL_SETUP( void ) {//Setup registers for external interrupt //P1DIR &= ~BIT1 ; P1OUT |= BIT1 ; // Set P1.1 to Pullup mode P1REN |= BIT1 ; // Enable P1.1 internal resistance P1IES |= BIT1 ; // P1.1 Hi/Lo edge P1IE |= BIT1 ; // P1.1 interrupt enabled P1IFG &= 0x00 ; // P1 IFG cleared return ; } void READ_ACCELERATION( void ) {// Read acceleration data from the accelerometer //Define local variables const int target = 140 ; uint8_t howManyBytesToRead = 6; readFrom( DATAX0, howManyBytesToRead, _buff); // each axis reading comes in 10 bit resolution, ie 2 bytes. Least Significat Byte first!! // thus we are converting both bytes in to one int accel_data[0] = (((int)_buff[1]) << 8) | _buff[0]; accel_data[1] = (((int)_buff[3]) << 8) | _buff[2]; accel_data[2] = (((int)_buff[5]) << 8) | _buff[4]; if( accel_data[0] >= target || accel_data[1] >= target || accel_data[2] >= target ) flag = 0x08 ; return ; } void READ_ADC( void ) { ADC12CTL0 |= ADC12SC; // Start conversion-software trigger while ( !( ADC12IFG ) ); //Reading ADC12 memory registers snd = ADC12MEM0 ; temp = ADC12MEM1 ; if( ( flag>>4 )&1 ) // flag = 0b1xxxx = 0x1x //Every 10 seconds {//If TEMP if( temp >= 0x2460 ) // ADC12MEM1 = A0 > 3.3V? { flag |= BIT0 ; //flag = 0bxxx1 } } if( snd >= 0x0A00 ) //Loud noise { flag |= BIT1 ; //flag = 0bxx1x } } /* //Define Interupts #pragma vector = ADC12_VECTOR __interrupt void ADC12_ISR_1( void ) {//ADC ISR snd = ADC12MEM0 ; //temp = ADC12MEM1 ; if( ( flag>>4 )&1 ) // flag = 0b1xxxx {//If TEMP if( temp >= 0x0000 ) // ADC12MEM = A0 > 3.3V? { flag |= BIT0 ; //flag = 0bxxx1 } } else {//ELSE MIC if( snd >= 0x0A00 ) //Loud noise { flag |= BIT1 ; //flag = 0bxx1x } } ADC12CTL0 |= ADC12SC ; //Clear CPUOFF bit __bic_SR_register_on_exit( CPUOFF ) ; }*/ #pragma vector = PORT1_VECTOR __interrupt void Port_1( void ) {//External Button ISR //Start timer for multifunction button TA2CTL |= MC_1 ; // Starting the timer counting up //Clear interrupt flag P1IFG &= ~BIT1 ; } #pragma vector = TIMER2_A0_VECTOR __interrupt void TIMER0_A2( void ) {//Timer A0 ISR, runs every 1 sec //Server Ping and ADC if( ( ( tmr_cnt%10 )^1 ) == 1 ) { // Ping server every 10 minutes flag = 0x10 ; //Send ping to server tmr_cnt = 0 ; } //Button function if( ( btn_cnt == 2 ) & ( ( flag>>5 )&1 ) ) { //Turn everything on } else if( btn_cnt == 5 ) // After 5 seconds, reset flag flag = 0x10 ; else if ( btn_cnt == 10 ) // After 10 seconds, turn off all interrupts { TA2CTL &= ~MC_1 ; // Turn off timer //DISABLE ALL OTHER MODULES flag = 0x20 ; P1IE |= BIT1 ; // P1.1 interrupt enabled } //Button "pattern" if( P1IN == 0xF0 ) //Masks btn_cnt++ ; else { btn_cnt = 0 ; } tmr_cnt++ ; //Clear interrupt flag TA2CTL &= ~TAIFG ; } Final.ino
  3. I have a problem with I2C and the MSP430G2553. Here is my Code: #include <msp430g2553.h> const unsigned char Init[] = {0xAE,0x81,0x07,0x20,0x01,0x21,0x00,0x7F,0x22,0x00,0x07,0x40,0xA0,0xA8,0x3F,0xC0,0xD3,0x00,0x8D,0x14,0xDA,0x12,0xD5,0x80,0xD9,0x22,0xDB,0x20,0xA6,0xA4,0xAF}; const unsigned char Mod[] = {0xA5}; void printC(const unsigned char* Array, unsigned int length){ UCB0CTL1 = UCSWRST; UCB0CTL0 = UCMODE_3 + UCMST + UCSYNC; // I2C master mode UCB0CTL1 = UCSSEL_2 + UCSWRST; // Use SMCLK, keep SW reset UCB0BR0 = 0x40; // < 100 kHz UCB0I2CSA = 0x3C; // address UCB0CTL1 &= ~UCSWRST; IE2 |= UCB0TXIE; // Enable TX ready interrupt //UCB0I2CIE = UCNACKIE; UCB0CTL1 |= UCTR + UCTXSTT; // I2C TX, start condition unsigned int c; for(c = 0; c < length; c++){ __bis_SR_register(LPM3_bits + GIE); UCB0TXBUF = 0x80; __bis_SR_register(LPM3_bits + GIE); UCB0TXBUF = Array[c]; //__bis_SR_register(LPM3_bits + GIE); } __bis_SR_register(LPM3_bits + GIE); UCB0CTL1 |= UCTXSTP; IE2 &= ~UCB0TXIE; IFG2 &= ~UCB0TXIFG; } void main(void){ WDTCTL = WDTPW + WDTHOLD; DCOCTL = CALDCO_8MHZ; //DCO setting = 8MHz BCSCTL1 = CALBC1_8MHZ; //DCO setting = 8MHz // Configure Pins for I2C P1SEL |= BIT6 + BIT7; // Pin init P1SEL2 |= BIT6 + BIT7; // Pin init printC(Init,31); __delay_cycles(8000000); printC(Mod,1); while(1); } // USCI_B0 Data ISR #pragma vector = USCIAB0TX_VECTOR __interrupt void USCIAB0TX_ISR(void){ __bic_SR_register_on_exit(LPM3_bits); // Wakeup main code IFG2 &= ~UCB0TXIFG; } The first printC works fine but in the second (printC(Mod,1) the processor stays in the low power mode forever after entering the for loop. Any ideas?
  4. Someone can helpme, i'm taking incorrect readings of a magnetometer I believe with the problem are in my i2c code implementation. /* * Print all printable characters on usb channel using UART mode of USCI module * the print is based in busy wait to transfer characters */ #include "msp/msp430g2553.h" void configureDCO(); void configureUART(); void putc(char); void print (const char[]); void print (short); void printStatus(); main() { configureDCO(); configureUART(); UCB0CTL1 = UCSWRST; //Reset USCI UCB0CTL0 = // USCI_B0 control register UCMST // set master mode | UCMODE_3 // I2C mode select | UCSYNC; // synchronous UCB0CTL1 = // UCSI_B0 control register UCSSEL_2 //select clock source, SMCLK | UCSWRST; UCB0I2CSA = 0x1e; // write desired slave address to the UCBxI2CSA, magnetometer address // prescaler to generate 75 Hz (1MHz of SMCLK / 13981 of prescaler) UCB0BR0 = 0x9D; UCB0BR1 = 0x36; //configure ports P1SEL |= BIT6 | BIT7; P1SEL2|= BIT6 | BIT7; UCB0CTL1 &= ~UCSWRST; // Initializate USCI print("[system] I2C configured\r\n"); // send start to transmit UCB0CTL1 |= UCTR // setting UCTR for transmitter mode | UCTXSTT; // setting UCTXSTT to generate START condition // point to register A ( address 0x00 ) while ( !(IFG2 & UCB0TXIFG) ); // wait UCBxTXIFG are set, when set the buffer are empty UCB0TXBUF = 0x00; // load data to be trasmitted on UCBxTXBUF // write 0x78 in register A, mean of eight measurements, 75 Hz sample rate while ( !(IFG2 & UCB0TXIFG) ); // wait UCBxTXIFG are set, when set the buffer are empty UCB0TXBUF = 0x78; // load data to be trasmitted on UCBxTXBUF // point to register B ( address 0x01 ) while ( !(IFG2 & UCB0TXIFG) ); // wait UCBxTXIFG are set, when set the buffer are empty UCB0TXBUF = 0x01; // load data to be trasmitted on UCBxTXBUF // write 0xa0 in register B, gain five while ( !(IFG2 & UCB0TXIFG) ); // wait UCBxTXIFG are set, when set the buffer are empty UCB0TXBUF = 0xa0; // load data to be trasmitted on UCBxTXBUF // point to mode register ( address 0x02 ) while ( !(IFG2 & UCB0TXIFG) ); // wait UCBxTXIFG are set, when set the buffer are empty UCB0TXBUF = 0x02; // load data to be trasmitted on UCBxTXBUF // write 0x00 in mode register, continuous operation while ( !(IFG2 & UCB0TXIFG) ); // wait UCBxTXIFG are set, when set the buffer are empty UCB0TXBUF = 0x00; // load data to be trasmitted on UCBxTXBUF // send stop UCB0CTL1 |= UCTXSTP; // send stop while (UCB0CTL1 & UCTXSTP); // wait STOP condition is ack __delay_cycles(6000); // wait 6ms, until change the settings of magnetometer // send start to receive UCB0CTL1 &= ~UCTR; // setting UCTR for receiver mode UCB0CTL1 |= UCTXSTT; // setting UCTXSTT to generate START condition while (UCB0CTL1 & UCTXSTT); // infinit loop, show continually the measuread values while (true) { // allocate space to the measured values, (x,y,z) coordinates, high byte (h prefix), low byte (l prefix) char hx, lx, hz, lz, hy, ly; // receive data output X MSB register while (!(IFG2 & UCB0RXIFG) ); // wait UCBxRXIFG are set, when set read buffer are full hx = UCB0RXBUF; // load data from buffer to local memory // receive data output X LSB register while (!(IFG2 & UCB0RXIFG) ); // wait UCBxRXIFG are set, when set read buffer are full lx = UCB0RXBUF; // load data from buffer to local memory // receive data output Z MSB register while (!(IFG2 & UCB0RXIFG) ); // wait UCBxRXIFG are set, when set read buffer are full hz = UCB0RXBUF; // load data from buffer to local memory // receive data output Z LSB register while (!(IFG2 & UCB0RXIFG) ); // wait UCBxRXIFG are set, when set read buffer are full lz = UCB0RXBUF; // load data from buffer to local memory // receive data output Y MSB register while (!(IFG2 & UCB0RXIFG) ); // wait UCBxRXIFG are set, when set read buffer are full hy = UCB0RXBUF; // load data from buffer to local memory // receive data output Y LSB register while (!(IFG2 & UCB0RXIFG) ); // wait UCBxRXIFG are set, when set read buffer are full ly = UCB0RXBUF; // load data from buffer to local memory // compose (x, y, z) values short x, y, z; x = (static_cast<short>(hx) << 8) | lx; // compose x MSB and LSB z = (static_cast<short>(hz) << 8) | lz; // compose z MSB and LSB y = (static_cast<short>(hy) << 8) | ly; // compose y MSB and LSB //print (x, y, z) measured values print("( "); print(x); print(", "); print(y); print(", "); print(z); print(" )"); print("\r\n"); } } void configureDCO() { WDTCTL = WDTPW + WDTHOLD; // Stop WDT // Set DCO to 1MHz BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; __delay_cycles(1000000); } void configureUART() { UCA0CTL1 |= UCSWRST; // put USCI in reset mode // P1.1 = RXD, P1.2=TXD P1SEL |= BIT1 | BIT2; P1SEL2 |= BIT1 | BIT2; UCA0CTL1 |= UCSSEL_3; // Use SMCLK // Set baud rate to 9600 with 1MHz clock (Data Sheet 15.3.13) 1MHz / 104 UCA0BR0 = 104; UCA0BR1 = 0; UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1, correction for the fractional part ( the rest, 9600 - 1MHz / 104) UCA0CTL1 &= ~UCSWRST; // put USCI in operad mode (removing reset mode) /*End configuration hardware UART */ print("[system] uart configured\r\n"); }; void putc(char ch) { while(!(IFG2 & UCA0TXIFG)); UCA0TXBUF = ch; } void print (const char msg[]) { for (int i = 0; msg[i] != '\0'; ++i) putc(msg[i]); } void print (short value) { if (value == 0) { putc('0'); return; } if (value < 0) { putc('-'); value *= -1; } unsigned int size; char buffer[20]; for (size = 0; value; ++size, value /= 10) buffer[size] = value % 10; while (size) putc(buffer[--size] + '0'); } void printStatus() { print("Status:\n\r"); #define __PRINT_STATUS(X, MSG) if (UCB0STAT & X) print(#MSG "! "); __PRINT_STATUS(UCNACKIFG, nack); __PRINT_STATUS(UCALIFG, arbitration lost); __PRINT_STATUS(UCGC, receive general call); __PRINT_STATUS(UCBBUSY, bus busy); __PRINT_STATUS(UCSCLLOW, SCL low); __PRINT_STATUS(UCSTPIFG, stop received); __PRINT_STATUS(UCSTTIFG, start received); print("done\n\r"); } Please this is a old problem, someone can helpme? David Kennedy S. Araujo Computer Engineering Student (PUC GO)
  5. I'm relatively new to the MSP430 and microcontroller world. I have a MSP430G2553 and am interfacing to a MMA8453Q accelerometer. I have this working on a MSP430G2231 using USI and now want to move to a MSP430G2553 with USCI. I took the samples from slaa382 for master and master with repeated start from TI and modified the basic master code to what I thought would provide me a repeated start option. I'm just trying to read back the "whoami" register but I think something is wrong with my repeated start implementation, could someone advise me on this? I've got 10k pull ups on the clock and data lines and was able to write to a DAC successfully so I am confident in my hardware setup. See attached files, basically I added a repeated start flag to the i2c master.c file which gets set when the "TI_USCI_I2C_transmitre" function gets called, then added if statements in the vector section which strips out the stop when the flag is set. Any help is appreciated, Thanks! Mark Copy of main.cTI_USCI_I2C_master.hTI_USCI_I2C_master_edit.c
  6. I've been banging my head against the wall trying to get even the most basic USCI I2C slave examples working with the g2553. I'm using a Bus Pirate (which acts as a i2c master) at 100Khz to send bytes to the g2553 (slave). I'm using an untouched example from slac485a (Examples for MSP430g2xx3) -- msp430g2xx3_uscib0_i2c_09.c .. Here it is below (since it's fairly short): //****************************************************************************** // MSP430G2xx3 Demo - USCI_B0 I2C Slave RX multiple bytes from MSP430 Master // // Description: This demo connects two MSP430's via the I2C bus. The master // transmits to the slave. This is the slave code. The interrupt driven // data receiption is demonstrated using the USCIB0 RX interrupt. // ACLK = n/a, MCLK = SMCLK = default DCO = ~1.2MHz // // /|\ /|\ // MSP430G2xx3 10k 10k MSP430G2xx3 // slave | | master // ----------------- | | ----------------- // -|XIN P3.1/UCB0SDA|<-|---+->|P3.1/UCB0SDA XIN|- // | | | | | // -|XOUT | | | XOUT|- // | P3.2/UCB0SCL|<-+----->|P3.2/UCB0SCL | // | | | | // // D. Dang // Texas Instruments Inc. // February 2011 // Built with CCS Version 4.2.0 and IAR Embedded Workbench Version: 5.10 //****************************************************************************** #include "msp430g2553.h" unsigned char *PRxData; // Pointer to RX data unsigned char RXByteCtr; volatile unsigned char RxBuffer[128]; // Allocate 128 byte of RAM void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT P1SEL |= BIT6 + BIT7; // Assign I2C pins to USCI_B0 P1SEL2|= BIT6 + BIT7; // Assign I2C pins to USCI_B0 UCB0CTL1 |= UCSWRST; // Enable SW reset UCB0CTL0 = UCMODE_3 + UCSYNC; // I2C Slave, synchronous mode UCB0I2COA = 0x48; // Own Address is 048h UCB0CTL1 &= ~UCSWRST; // Clear SW reset, resume operation UCB0I2CIE |= UCSTPIE + UCSTTIE; // Enable STT and STP interrupt IE2 |= UCB0RXIE; // Enable RX interrupt while (1) { PRxData = (unsigned char *)RxBuffer; // Start of RX buffer RXByteCtr = 0; // Clear RX byte count __bis_SR_register(CPUOFF + GIE); // Enter LPM0 w/ interrupts // Remain in LPM0 until master // finishes TX __no_operation(); // Set breakpoint >>here<< and read } // read out the RxData buffer } //------------------------------------------------------------------------------ // The USCI_B0 data ISR is used to move received data from the I2C master // to the MSP430 memory. //------------------------------------------------------------------------------ #pragma vector = USCIAB0TX_VECTOR __interrupt void USCIAB0TX_ISR(void) { *PRxData++ = UCB0RXBUF; // Move RX data to address PRxData RXByteCtr++; // Increment RX byte count } //------------------------------------------------------------------------------ // The USCI_B0 state ISR is used to wake up the CPU from LPM0 in order to // process the received data in the main program. LPM0 is only exit in case // of a (re-)start or stop condition when actual data was received. //------------------------------------------------------------------------------ #pragma vector = USCIAB0RX_VECTOR __interrupt void USCIAB0RX_ISR(void) { UCB0STAT &= ~(UCSTPIFG + UCSTTIFG); // Clear interrupt flags if (RXByteCtr) // Check RX byte counter __bic_SR_register_on_exit(CPUOFF); // Exit LPM0 if data was } // received The MSP430 successfully interrupts on start conditions, but sending any data does not trigger the USCIAB0TX interrupt and it appears the MSP430 holds SDA low (presumably because UCB0RXBUF is not being read, since the interrupt is not being triggered). I've tripled checked my pinouts (1.6 and 1.7, even tried swapping them at the suggestion of google, but no luck). I've removed the jumper on Pin 1.6. I'm using 10k pull up resistors that are working. I've read the user guide, datasheet, and countless websites, but I just can't seem to figure this out. Am I doing something stupid or is this example code just plain wrong?
×
×
  • Create New...