Jump to content
Forum sending old emails Read more... ×

Search the Community

Showing results for tags 'i2c'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • 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


There are no results to display.

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Website URL





Found 104 results

  1. Solexious

    I2C issue with tiva C

    Hey all, I've currently got an issue where i2c just isn't working with energia, I've opened an issue on github but haven't gotten any replies. Is there a better way to get some eyes on this? Would anyone here mind taking a look? https://github.com/energia/tivac-core/issues/41 Cheers Sol
  2. jsolarski

    Brew day monitor suite

    This is a start to a bigger project and will be expanded on. Temperurature sensor for Mash -- MSP430, LM75B, possible other sensors, thermal couple. (working on code and proof of concept) Temperurature sensor for fermentation -- TBD Specific gravity sensor -- TBD User Interface -- TBD automation of pumps gas lines and equipment -- Requirements: Food safe, easily cleaned. probes and sensors sealed...... What I want is mash temp monitoring and logging to help me improve my brew days and procedure and maybe add a heater to keep the tempature stable during this time. Yes this has all been done before, but I want a home built one and one customized to my equipment.
  3. Hi, At a previous project I turn on and off power to ST LIS3DH Accelerometer using a MOSFET Circuitry. This is so to make sure the I2C Sensor is not consuming current when not in use. A colleague of mine designed to power a ST LSM303AGR from one of the MCU IO Pins. The MCU IO voltage is enough to power the ST LSM303AGR, so, should work. But, powering I2C Sensor from MCU IO Pins is not the usual way and new to me. Do you think that powering the ST LSM303AGR from one of the MCU IO Pin is okay or is not recommended? Regards, Markel
  4. Hello, I am trying to get RED, IR and GREEN led value in real time from MAX30101 sensor. I am using MSP430F5438A as my MCU. My IDE is CCS. The protocol required to communicate with the sensor is I2C. Now my problem is I am not any value except 0 in my read and write pointer (Indicated in the comment in my code). I am supposed to get some value in between 0 to 32. I'm attaching the link for the datasheet for the sensor: https://datasheets.maximintegrated.com/en/ds/MAX30101.pdf I know the datasheet is a whole lot. But I am referring page 17 which they have a pseudo code how to burst read the FIFO. If anyone already worked with the sensor or anyone know please have a look at it. #include <msp430.h> #include <msp430f5438a.h> #include <string.h> #define MAX30101_I2C_ADDRESS 0x57 #define MAX30101_REG_INT_STS1 0x00 #define MAX30101_REG_INT_STS2 0x01 #define MAX30101_REG_INT_EN1 0x02 #define MAX30101_REG_INT_EN2 0x03 #define MAX30101_REG_FIFO_WR 0x04 #define MAX30101_REG_FIFO_OVF 0x05 #define MAX30101_REG_FIFO_RD 0x06 #define MAX30101_REG_FIFO_DATA 0x07 #define MAX30101_REG_FIFO_CFG 0x08 #define MAX30101_REG_MODE_CFG 0x09 #define MAX30101_REG_SPO2_CFG 0x0a #define MAX30101_REG_LED1_PA 0x0c #define MAX30101_REG_LED2_PA 0x0d #define MAX30101_REG_LED3_PA 0x0e #define MAX30101_REG_PILOT_PA 0x10 #define MAX30101_REG_MULTI_LED 0x11 #define MAX30101_REG_TINT 0x1f #define MAX30101_REG_TFRAC 0x20 #define MAX30101_REG_TEMP_CFG 0x21 #define MAX30101_REG_PROX_INT 0x30 void Clock_setup(); // default void MAX30101_setup(); // Sensor config setup void I2C_setup(); void sendByte(char register_add, char data); int readByte(char wr_add, char rd_add, char register_add); void burstRead(char wr_add, char rd_add, char register_add, int no_ofsample); void FIFO_Clear(); char LED1 [96]; char LED2 [96]; char LED3 [96]; long L1[32]; long L2[32]; long L3[32]; int wr; int rd; int Ns; // number of available sample void main() { WDTCTL = WDTPW + WDTHOLD; Clock_setup(); I2C_setup(); _EINT(); MAX30101_setup(); while(1){ //FIFO_Clear(); wr= readByte(0xAE, 0xAF, 0x04); // reading WR_PTR---> I don't know why getting zero rd= readByte(0xAE, 0xAF, 0x06); // reading RD_PTR---> I don't know why getting zero Ns = wr-rd; if(Ns<0){ Ns+=32; } if(wr != rd){ burstRead(0xAE, 0xAF, 0x07, Ns); } } } void Clock_setup(){ P11DIR |= BIT2; // check smclk, 1MHz default P11SEL |= BIT2; // check smclk, 1MHz default P11DIR |= BIT0; // check aclk, 32.8KHz default P11SEL |= BIT0; // check aclk, 32.8KHz default } void I2C_setup() { P3SEL |= BIT7; // P3.1(UCB0_SDA), P3.2(UCB0_SCL) P5SEL |= BIT4; UCB1CTL1 |= UCSWRST; // reset enable UCB1CTL0 = UCMST + UCMODE_3 + UCSYNC; // master + I2C mode + Sync UCB1CTL1 = UCSSEL_2 + UCSWRST; //use SMCLK + still reset UCB1BR0 = 10; // default SMCLK 1M/10 = 100KHz.........? UCB1BR1 = 0; // UCB1I2CSA = MAX30101_I2C_ADDRESS; // MAX30101 7 bit address 0x57 UCB1CTL1 &= ~UCSWRST; // reset clear // UCB1IE |= UCTXIE + UCRXIE; //TX and RX interrupt enabled } //Single Byte Transmit (TX) void sendByte(char register_add, char data){ // UCB0I2CSA = slave_add; //slave address for transmit mode UCB1CTL1 |= UCTR + UCTXSTT; // I2C transmit (write) mode + generating START condition UCB1TXBUF = register_add; //register address to measure temperature/pressure while(!(UCB1IFG & UCTXIFG)); //wait until reg address got sent while(UCB1CTL1 & UCTXSTT); //wait till START condition is cleared UCB1TXBUF = data; //send data to register while(!(UCB1IFG & UCTXIFG)); //wait until data got sent UCB1CTL1 |= UCTXSTP; //generate a STOP condition while(UCB1CTL1 & UCTXSTP); //wait until stop condition got sent } //Single Byte Receive (RX) int readByte(char wr_add, char rd_add, char register_add){ int rx_byte; //UCB0I2CSA = slave_add; //slave address UCB1CTL1 |= UCTXSTT + UCTR; // Generating START + I2C transmit (write) UCB1TXBUF = wr_add; //write register address while(!(UCB1IFG & UCTXIFG)); //wait until reg address got sent UCB1TXBUF = register_add; //write register address while(!(UCB1IFG & UCTXIFG)); //wait until reg address got sent while( UCB1CTL1 & UCTXSTT); //wait till START condition is cleared UCB1CTL1 |= UCTXSTT; //generate RE-START //UCB1I2CSA = slave_add; //slave address UCB1TXBUF = rd_add; //write register address while(!(UCB1IFG & UCTXIFG)); //wait until reg address got sent UCB1CTL1 &=~ UCTR; //receive mode while( UCB1CTL1 & UCTXSTT); //wait till START condition is cleared rx_byte = UCB1RXBUF; //read byte UCB1CTL1 |= UCTXSTP; //generate stop condition while(UCB1CTL1 & UCTXSTP); //wait till stop condition got sent return rx_byte; } //Multiple Byte Receive (RX) void burstRead(char wr_add, char rd_add, char register_add, int no_ofsample){ unsigned int i; //UCB1I2CSA = slave_add; //slave address //while(!(UCB1IFG & UCTXIFG)); //wait until slave address got sent UCB1CTL1 |= UCTXSTT + UCTR; // Generating START condition + I2C transmit (write) UCB1TXBUF = wr_add; //write register address while(!(UCB1IFG & UCTXIFG)); //wait until reg address got sent UCB1TXBUF = register_add; //write register address while(!(UCB1IFG & UCTXIFG)); //wait until reg address got sent while( UCB1CTL1 & UCTXSTT); //wait till START condition is cleared UCB1CTL1 |= UCTXSTT; //generate RE-START condition //UCB1I2CSA = slave_add; //slave address UCB1TXBUF = rd_add; //write register address while(!(UCB1IFG & UCTXIFG)); //wait until reg address got sent UCB1CTL1 &=~ UCTR; //receive mode while( UCB1CTL1 & UCTXSTT); //wait till START condition is cleared //buffer[0] = UCB1RXBUF; //dummy read //while(!(UCB1IFG & UCRXIFG)); //wait till byte is completely read for(i=0;i<no_ofsample;++i){ LED1 = UCB1RXBUF; //burst read while(!(UCB1IFG & UCRXIFG)); //wait while the Byte has being read LED1[i+1] = UCB1RXBUF; //burst read while(!(UCB1IFG & UCRXIFG)); //wait while the Byte has being read LED1[i+2] = UCB1RXBUF; //burst read while(!(UCB1IFG & UCRXIFG)); //wait while the Byte has being read L1= ((LED1 << 16) | (LED1[i+1] << 08 | LED1[i+2]) & 0x03FFFF; LED2 = UCB1RXBUF; //burst read while(!(UCB1IFG & UCRXIFG)); //wait while the Byte has being read LED2[i+1] = UCB1RXBUF; //burst read while(!(UCB1IFG & UCRXIFG)); //wait while the Byte has being read LED2[i+2] = UCB1RXBUF; //burst read L2= ((LED2 << 16) | (LED2[i+1] << 08 | LED2[i+2]) & 0x03FFFF; while(!(UCB1IFG & UCRXIFG)); //wait while the Byte has being read LED3 = UCB1RXBUF; //burst read while(!(UCB1IFG & UCRXIFG)); //wait while the Byte has being read LED3[i+1] = UCB1RXBUF; //burst read while(!(UCB1IFG & UCRXIFG)); //wait while the Byte has being read LED3[i+2] = UCB1RXBUF; //burst read while(!(UCB1IFG & UCRXIFG)); //wait while the Byte has being read L3= ((LED3 << 16) | (LED3[i+1] << 08 | LED3[i+2]) & 0x03FFFF; } //buffer[no_ofBytes-1] = UCB1RXBUF; //last Byte read //while(!(UCB1IFG & UCRXIFG)); //wait UCB1CTL1 |= UCTXSTP; //generate stop condition //while(UCB1CTL1 & UCTXSTP); //wait till stop condition got sent } // Sample Average = 4 // Mode = MultiLED // ADC Range = 2048 // Sample rate = 400 //pulse width = 411 // active slot 01, 02 and 03 void MAX30101_setup(){ sendByte(0x08, 0x40); sendByte(0x09, 0x07); sendByte(0x0A, 0x0F); sendByte(0x11, 0x77); sendByte(0x12, 0x07); } void FIFO_Clear(){ sendByte(0x04, 0x00); sendByte(0x05, 0x00); sendByte(0x06, 0x00); } Thanks, Rowshon.
  5. Hi everyone I am beginner and I want to use the adxl345 with msp430g2553 with I2C, but the example that I am using don´t working, always send 0 in the axes x,y and z. I use energia 1.6.10e18, the circuit have the pull'up resistor in SDA and SCL pines, and I remove the jumper of the green led. I used the same code but with arduino and it working but with enegia not, help me please. My launchpad is MSP-EXP430G2 rev 1.5 The SCL is connected in pin 14 and the SDA in pin 15. My OS is windows 7 When i put this function "Wire.setModule(0)" the mcu does make nothing, the uart don´t send nothing. The code is the follow: #include <Wire.h> void setup() { Serial.begin(9600); Serial.print("Iniciado"); Wire.begin(); writeTo(DATA_FORMAT, 0x01); //Put the ADXL345 into +/- 4G range by writing the value 0x01 to the DATA_FORMAT register. writeTo(POWER_CTL, 0x08); //Put the ADXL345 into Measurement Mode by writing 0x08 to the POWER_CTL register. } void loop() { uint8_t howManyBytesToRead = 6; readFrom( DATAX0, howManyBytesToRead, _buff); //read the acceleration data from the ADXL345 int X = (((int)_buff[1]) << 😎 | _buff[0]; int Y = (((int)_buff[3]) << 😎 | _buff[2]; int Z = (((int)_buff[5]) << 😎 | _buff[4]; Serial.print("x: "); Serial.print( X ); Serial.print(" y: "); Serial.print( Y ); delay(500); } 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 } 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) { digitalWrite(RED_LED,HIGH); _buff = Wire.read(); // receive a byte i++; } Wire.endTransmission(); // end transmission }
  6. Hello, I'm working on msp430fr4133 board and interface SHTC3 (SENSIRION) sensor. I'm working on energia v.18 IDE. I've library of SHTC3 sensor based library.this library perfectly working in Arduino board. But same library and its example sht-detect not working in energia IDE. When I refer SHTC3 compatible library file .h and .cpp. if I'm comparing datasheet and library files then in .cpp not mention any hex address e.g Reset,ID, measure, sleep, wake up. So,I have a 2 queries : (i) How this file working in arduino without addresses ? (ii) How to make energia compatible code by using attached library ? Please suggest me sample code for SHTC3 (SENSIRION). PFA. Thanks & Regards, Pratik arduino-sht-master.zip Sensirion_Humidity_Sensors_SHTC3_Datasheet.pdf
  7. Hello, everyone! Has anyone used the I2C display module with the TM4C123 Launchpad? I'm trying to use this code as a test, but I was not successful. The version of the library I am using is 1.2.1 I accept other suggestions for using the i2c display. Thanks in advance! The code: #include <Wire.h> #include <LiquidCrystal_I2C.h> // Start the I2C address at 0x27 position LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7,3, POSITIVE); void setup() { lcd.begin (16,2); } void loop() { lcd.setCursor(0,0); lcd.print("test line 1"); lcd.setCursor(1,1); lcd.print("test line 2"); } The error: In file included from C:\Users\Marcos\Documents\Energia\libraries\LiquidCrystal\FastIO.cpp:32:0: C:\Users\Marcos\Documents\Energia\libraries\LiquidCrystal\FastIO.h:38:52: fatal error: pins_arduino.h: No such file or directory #include <pins_arduino.h> // pleasing sanguino core ^ compilation terminated. exit status 1
  8. Hi, I posted a question on e2e but I found interesting to ask here too. I'm trying to port the Adafruit MCP4725 library to MSP430 using the Driverlib. I'm testing with launchpad EXP43FR2433 running at 1MHz and I would not want to use interruption to keep the code more portable. The sequence to write some value on DAC is relatively simple. - Set address -> send start -> send write cmd -> send upper byte -> send lower byte -> send stop. Using the following code one byte of the value is lost. msp43x_I2C_setSlaveAddress(EUSCI_B0_BASE, _i2caddr); msp43x_I2C_masterSendStart(EUSCI_B0_BASE); msp43x_I2C_masterMultiByteNext(EUSCI_B0_BASE, controlBits); // write cmd msp43x_I2C_masterMultiByteNext(EUSCI_B0_BASE, dataBits / 16); // Upper data bits (D11.D10.D9.D8.D7.D6.D5.D4) msp43x_I2C_masterMultiByteNext(EUSCI_B0_BASE, (dataBits % 16) << 4); // Lower data bits (D3.D2.D1.D0.x.x.x.x) msp43x_I2C_masterMultiByteStop(EUSCI_B0_BASE); But if I insert some dummy code (__delay_cycles) the transmission starts to work. #define I2C_Delay 5 msp43x_I2C_setSlaveAddress(EUSCI_B0_BASE, _i2caddr); __delay_cycles(I2C_Delay); msp43x_I2C_masterSendStart(EUSCI_B0_BASE); __delay_cycles(I2C_Delay); msp43x_I2C_masterMultiByteNext(EUSCI_B0_BASE, controlBits); // write cmd __delay_cycles(I2C_Delay); msp43x_I2C_masterMultiByteNext(EUSCI_B0_BASE, dataBits / 16); // Upper data bits (D11.D10.D9.D8.D7.D6.D5.D4) __delay_cycles(I2C_Delay); msp43x_I2C_masterMultiByteNext(EUSCI_B0_BASE, (dataBits % 16) << 4); // Lower data bits (D3.D2.D1.D0.x.x.x.x) __delay_cycles(I2C_Delay); msp43x_I2C_masterMultiByteStop(EUSCI_B0_BASE); __delay_cycles(I2C_Delay); Someone knows what's happening? It looks like the library is not checking if the transmission was correctly performed. Thanks
  9. I am working on TM4C1294XL board and through Energia platform. I am trying to interface HMC5883L of GY-80 with TM4C1294XL board. I am getting static outputs irrespective of whether I initialize all the essential registers or initialize none, the static outputs do not change in both cases. I am pasting the code below, I suspect that something should be wrong with the code as there nothing much to do in connection (only four wires needed). #include "Wire.h" #define cra 0x00 #define crb 0x01 #define modeReg 0x02 #define data_X_MSB 0x03 #define data_X_LSB 0x04 #define data_Y_MSB 0x07 #define data_Y_LSB 0x08 #define data_Z_MSB 0x05 #define data_Z_LSB 0x06 #define statusReg 0x09 #define ID_reg_A 0x10 #define ID_reg_B 0x11 #define ID_reg_C 0x12 int magAddress = 0x1E; int X0,X1,Y0,Y1,Z0,Z1,X_out,Y_out,Z_out; float Xm,Ym,Zm; void setup(){ Wire.setModule(0); Wire.begin(); Serial.begin(115200); delay(100); Wire.beginTransmission(magAddress); Wire.write(modeReg); Wire.write(0x00); Wire.write(cra); Wire.write(0x38); Wire.write(crb); Wire.write(0xA0); Wire.write(data_X_MSB); Wire.write(0x00); Wire.write(data_X_LSB); Wire.write(0x00); Wire.write(data_Y_MSB); Wire.write(0x00); Wire.write(data_Y_LSB); Wire.write(0x00); Wire.write(data_Z_MSB); Wire.write(0x00); Wire.write(data_Z_LSB); Wire.write(0x00); Wire.endTransmission(); } void loop(){ Wire.beginTransmission(magAddress); Wire.write(data_X_LSB); Wire.write(data_X_MSB); Wire.endTransmission(); Wire.requestFrom(magAddress,2); if(Wire.available()<=2) { X0 = Wire.read(); X1 = Wire.read(); X1 = X1<<8; X_out = X0+X1; Xm = (X_out); } Wire.beginTransmission(magAddress); Wire.write(data_Y_LSB); Wire.write(data_Y_MSB); Wire.endTransmission(); Wire.requestFrom(magAddress,2); if(Wire.available()<=2) { Y0 = Wire.read(); Y1 = Wire.read(); Y1 = Y1<<8; Y_out = Y0+Y1; Ym = (Y_out); } Wire.beginTransmission(magAddress); Wire.write(data_Z_LSB); Wire.write(data_Z_MSB); Wire.endTransmission(); Wire.requestFrom(magAddress,2); if(Wire.available()<=2) { Z0 = Wire.read(); Z1 = Wire.read(); Z1 = Z1<<8; Z_out = Z0+Z1; Zm = (Z_out); } Serial.print("Xm = "); Serial.print(Xm); Serial.print("\t"); Serial.print("Ym = "); Serial.print(Ym); Serial.print("\t"); Serial.print("Zm = "); Serial.println(Zm); delay(200); }
  10. Still new to embedded programming and I am trying to use the MMA8452 accelerometer (datasheet) on SparkFun's breakout board (link). I programmed SparkFun's example program (link) into the MSP430G2553 via Energia with no issues and plotted the serial data in Excel. However this data, for lack of a better word, was "noisy." There would be huge spikes in the data even though the device was sitting still. Sometimes the WHO_AM_I value would be reported incorrectly as well. I found out the board shipped with 10k pull ups so I dropped them to the recommended 4.7k? resistors and the problem persisted. When I tried to investigate the SCL and SDA lines with my oscilloscope, the problem would disappear and the data would be a pristine flat line (as expected). That told me the scope probe capacitance was actually helping the circuit and rather than decrease resistance I should increase resistance. That seemed very counter intuitive to me, but I followed the data and changed pull ups to 15k. The problem disappeared and the data was clean. I was using short leads with and without a breadboard. The jumper to the Green LED was also removed from the SCL line. Being required to have 15k pull ups on the I2C bus seems wrong to me especially since the datasheet recommends 4.7k. Am I missing something? I am not well versed in I2C and Freescale's tech support has been less than helpful. I did order a MMA8451 sample and swapped it on SparkFun's breakout board and had the same problem. So I know the problem was not specific to that MMA8452. Other I2C devices (like the BQ32000) work fine.
  11. Rei Vilo

    I²C Check-List

    Check the usual suspects: Is the I²C bus initialised? Wire.begin(); Does the I²C device run at 3.3V? Otherwise, use a logic-level converter. Are pull-ups installed? Try 10, 4.7 or 2.2 kΩ for the SDA and SCL lines. In case the LaunchPad provides multiple I²C ports, is the correct port selected? Try Wire.setModule(0); // or other port number Wire.begin(); Still nothing? Use a logic analyser to trace the signals on the I²C port. (To be continued...)
  12. I am trying to interface GY-80 (only adxl345) to TM4C1294XL board using Energia. But outputs comes out to be 0. And also there comes this error "Failed to load dynamic library: 'ftd2xx.dll' " while uploading but the code gets uploaded successfully. I am pasting the code below, can somebody tell me where i am doing it wrong? #include "Wire.h" #define Power_Register 0x2D #define BW_rate 0x2C #define Int_enable 0x2E #define dataFormat 0x31 #define X_Axis_Register_DATAX0 0x32 #define X_Axis_Register_DATAX1 0x33 #define Y_Axis_Register_DATAY0 0x34 #define Y_Axis_Register_DATAY1 0x35 #define Z_Axis_Register_DATAZ0 0x36 #define Z_Axis_Register_DATAZ1 0x37 #define fifoCntrl 0x38 int ADXAddress = 0x53; int X0,X1,X_out; int Y0,Y1,Y_out; int Z1,Z0,Z_out; float Xa,Ya,Za; void setup() { Wire.setModule(0); Wire.begin(ADXAddress); Serial.begin(115200); delay(100); Wire.beginTransmission(ADXAddress); Wire.write(Power_Register); Wire.write(8); Wire.write(BW_rate); Wire.write(10); Wire.write(dataFormat); Wire.write(11); Wire.write(fifoCntrl); Wire.write(0); Wire.endTransmission(); } void loop() { Wire.beginTransmission(ADXAddress); Wire.write(X_Axis_Register_DATAX0); Wire.write(X_Axis_Register_DATAX1); Wire.endTransmission(); Wire.requestFrom(ADXAddress,2); if(Wire.available()<=2) { X0 = Wire.read(); X1 = Wire.read(); X1=X1<<8; X_out =X0+X1; } Wire.beginTransmission(ADXAddress); Wire.write(Y_Axis_Register_DATAY0); Wire.write(Y_Axis_Register_DATAY1); Wire.endTransmission(); Wire.requestFrom(ADXAddress,2); if(Wire.available()<=2) { Y0 = Wire.read(); Y1 = Wire.read(); Y1=Y1<<8; Y_out =Y0+Y1; } Wire.beginTransmission(ADXAddress); Wire.write(Z_Axis_Register_DATAZ0); Wire.write(Z_Axis_Register_DATAZ1); Wire.endTransmission(); Wire.requestFrom(ADXAddress,2); if(Wire.available()<=2) { Z0 = Wire.read(); Z1 = Wire.read(); Z1=Z1<<8; Z_out =Z0+Z1; } Serial.print("Xa= "); Serial.print(Xa);Serial.print("\t"); Serial.print("Ya= "); Serial.print(Ya);Serial.print("\t"); Serial.print("Za= "); Serial.println(Za); delay(1000); Serial.println(); }
  13. Hi everyone. I'm new to this forum and new to TI mcu. Planing to get a launchpad with msp430g2553 I have experience with atmegas, and arduino ide. I have a project to have some sensors around with batteries and a central receiver to publish to internet, the will comunicate vía nrf24l01 which is a SPI device and in the array of sensors some of them are I2C. As I see the description I2C and SPI share the pin in Msp430G2, so my question: is possible to use both in the same project in a reliable way? I did this project with atmega328 and arduino ide but I read the msp430g2553 has better power efficiency and want to give it a try.
  14. I'm trying to connect the HDC2010 temperature sensor to the MSP430FR5969 Launchpad. I'm using the HDC2010 EVM, which consists of a MSP430F5528 (which handles USB communications to the GUI tool) and a HDC2010 (connected over I2C). The portion with the HDC2010 can be broken off from the main board in order to use it with another MCU. I'm attempting to connect it to a MSP430FR5969 Launchpad which has the SHARP Memory LCD (uses SPI) connected to it. I couldn't find a ready made library for the HDC2010 & MSP430, so I copied over some code from the Arduino library. To check whether I was using the HDC2010 correctly, I first used the following code (mostly taken from the HDC2010 lib) and used an Arduino Uno. I used MOSFET level translators (since the Arduino is 5V, HDC2010 is 3.3). I did not break off the HDC2010 section from the main board of the EVM, so the main MSP430F5528 was still connected to the HDC2010, but I guess it was idle. #define ADDR 0x40 #include <Wire.h> //Define Register Map #define TEMP_LOW 0x00 #define TEMP_HIGH 0x01 #define HUMID_LOW 0x02 #define HUMID_HIGH 0x03 #define INTERRUPT_DRDY 0x04 #define TEMP_MAX 0x05 #define HUMID_MAX 0x06 #define INTERRUPT_CONFIG 0x07 #define TEMP_OFFSET_ADJUST 0x08 #define HUM_OFFSET_ADJUST 0x09 #define TEMP_THR_L 0x0A #define TEMP_THR_H 0x0B #define HUMID_THR_L 0x0C #define HUMID_THR_H 0x0D #define CONFIG 0x0E #define MEASUREMENT_CONFIG 0x0F #define MID_L 0xFC #define MID_H 0xFD #define DEVICE_ID_L 0xFE #define DEVICE_ID_H 0xFF float temperature = 0, humidity = 0; void openReg(uint8_t reg) { Wire.beginTransmission(ADDR); // Connect to HDC2010 Wire.write(reg); // point to specified register Wire.endTransmission(); // Relinquish bus control } uint8_t readReg(uint8_t reg) { openReg(reg); uint8_t reading; // holds byte of read data Wire.requestFrom(ADDR, 1); // Request 1 byte from open register Wire.endTransmission(); // Relinquish bus control if (1 <= Wire.available()) { reading = (Wire.read()); // Read byte } return reading; } float readTemp(void) { uint8_t byte[2]; uint16_t temp; byte[0] = readReg(TEMP_LOW); byte[1] = readReg(TEMP_HIGH); temp = (unsigned int)byte[1] << 8 | byte[0]; return (float)(temp) * 165 / 65536 - 40; } void writeReg(uint8_t reg, uint8_t data) { Wire.beginTransmission(ADDR); // Open Device Wire.write(reg); // Point to register Wire.write(data); // Write data to register Wire.endTransmission(); // Relinquish bus control } void setup() { // put your setup code here, to run once: Serial.begin(9600); Wire.begin(); } void loop() { // put your main code here, to run repeatedly: Serial.println(temperature = readTemp()); //Serial.println(humidity = readHumidity()); delay(1000); } This code worked and I got temperature readings. Next, I tried it out on the MSP430FR5969, again, without breaking off the sensor from the mainboard. It didn't work at first, so I checked with a logic analyzer and if I recall correctly, either the SCK or SDA lines wasn't sending any data. However, after sometime it started working properly, and then stopped again. After trying for a couple of hours, I decided to disconnect the HDC2010 from the mainboard, in case the MSP430F5528 was causing some issues. I connected the HDC2010 to the Arduino Uno via the logic level shifter, and the code worked correctly. However, it doesn't work with the MSP430FR5969. I tried out the inbuilt Wire examples, and the logic analyzer reveals that the I2C lines don't seem to be sending data at all (they work fine as GPIO). I'm using pins 9 & 10 on a Rev2.0 launchpad. What's odd is that it worked for a little while & I cannot figure out what I'm doing wrong. This is with a 1.2k ohm pull up on the clock line (2nd row). Without the pull up, the line remains low. The first row shows SDA, but the logic is inverted for some reason, and if I use a 10k pull up, it remains high continuously. I managed to capture this when it worked correctly with the MSP430FR5969: I've read conflicting reports about the actual I2C pins on the MSP430FR5969 launchpad: are they at 9 & 10 (as the board pdf & silkscreen says), or have they been shifted to the same pins as SPI? What's the best way to debug this? Simple I2C sketches don't seem to work for some reason, but it worked correctly for a little while.
  15. biza

    MSP432P401R I2C +TMP006

    Hi fellows, I have some facing some problems with interface on sensor TMP006, now I have done the I2C driver in CMSIS, the problem is in the TMP006 file, I can not configure the registers to make the conection with i2c protocol I2C.c I2C.h tmp006.c tmp006.h
  16. ThisIsMe

    MSP430 and I2C

    I have been trying to use a simple I2C sensor (LM75) with a MSP430FR5994. I find there are two pin maps. One at Energia (http://energia.nu/wordpress/wp-content/uploads/2016/11/Capture-2016-11-30-à-15.10.44.png) and one at TI directly (http://www.ti.com/lit/ml/slau677/slau677.pdf) on page 2. I have tried using I2C (1) as indicated at in the TI reference, and I have tried I2C (2) as indiicated in the Energia reference. neither one work. I can use an Arduino to access the sensor so I have some hope that this might work. What pins do I need to use to use I2C? Is there a library call to specify which I2C pins to use? By the way, I can connect to the board and load the blink sample, and I can do serial communication, so board connectivity is OK, I2C is not. Gerald
  17. ConfusedCoder

    MSP430G2553 & HT16K33 Issues

    Hi, I'm having a lot of trouble figuring out how to communicate with this Adafruit 7-segment display. I've looked through the Adafruit LED library, seen non-MSP microcontrollers working with the code, tried understanding the HT16K33 datasheet. I've even recorded the SCL and SDA signals from my Arduino connecting with the 7-segment. However, I'm still not sure how to get it to work with my MSP430G2553 or even how to get started. Though, I have looked into the MSP430 example code for i2c communications with the MSP430 as the master. Is it as simple as just converting the Adafruit LED library from C++ to C? I didn't expect interfacing with a 7-segment display to be so difficult for me. Any advice is much appreciated.
  18. abc1

    MSP430g2552 i2c clock issue

    I am interfacing msp430 with rtc using i2c protocols.here is the program: WDTCTL = WDTPW + WDTHOLD; P1SEL |= BIT6 +BIT7; P1SEL2|= BIT6 +BIT7; UCB0CTL1 |= UCSWRST; UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC;// I2C Master, synchronous mode UCB0CTL1 = UCSSEL_2 ; UCB0BR0 = 12; UCB0BR1 = 0; UCB0I2CSA = 0x34; UCB0CTL1 &= ~UCSWRST ; //everythingis fine upto here.scl is high here. UCB0CTL1 |= UCTR + UCTXSTT; /// here scl clock goes low. uctr=1 but uctxstt=0. any suggestions??
  19. Hello it looks like I bumped into an issue which might be of interest, and needs to be investigated. I have a string of I2C devices running on i2C Bus on Arduino Mega (MCP4531 potti, LM-75 Temp sensor, 2x PCF 8575 I/Expanders). All running smooth. The next step I had to exchange the Mega with Tiva Stellaris Launchpad (EK-TM4C129E ), which I did, I havent changed anything on the setup besides the Mega2560 with Launchpad. While running the i2C scanner I saw, full Bus of devives. Furthermore I changed the i2C modules (0,1,2 with setModule()) nothing changed, same issue persists. Pull-ups varied from 1KOhm - 9Kohm, still same issue. Anyone experienced something like that before?
  20. Register

    SPI + I2C

    Hi, I'm trying to make a clock with a Tiny RTC module and a iTead 5110 Nokia LCD. I'm using Adafruit RTClib and the energia LCD_5110_SPI. Each library an device are working fine separately but when put together it stops working, is it possible to have SPI and I2C device working simultaneously? Thanks.
  21. Hello everyone, I'm trying to use I2C0 on tm4c1294 to communicate with rtc ds1307/ am2315 but it doesn't work. I was tried read many threads about i2c issue on tiva c with no luck. Here are one of them: Have anyone successful using I2C on tiva C (tm4c1294ncpdt)? Guide me, pls.
  22. Hello, What is the status of Wire.h when using energia with the tiva-c board? Since there is the BoardManager in E18, the file layout has changed. Which leads to some confusion. eagle@daredevil:~$ find . -type f -name "Wire.h" ./.energia15/packages/energia/hardware/msp432/3.8.0/cores/msp432/ti/runtime/wiring/Wire.h ./.energia15/packages/energia/hardware/msp430/1.0.2/libraries/Wire/Wire.h ./.energia15/packages/energia/hardware/tivac/1.0.2/libraries/Wire/Wire.h ./.energia15/packages/energia/hardware/msp432r/5.6.0/cores/msp432r/ti/runtime/wiring/Wire.h ./bin/energia-1.6.10E18/hardware/energia/msp430/libraries/Wire/Wire.h ./bin/energia-1.6.10E18/hardware/energia/msp430/cores/msp430/Wire.h So I think when using energia with tivac, it will use the .energia15/packages/energia/hardware/tivac/1.0.2/libraries/Wire/Wire.h file that is in the hidden .energia directory right? Then I went ahead and edited the Wire.cpp file in the tivac/1.0.2 dir. #include <stdlib.h> #include <stdio.h> #include <string.h> #include <inttypes.h> #include "wiring_private.h" #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "inc/hw_ints.h" #include "inc/hw_i2c.h" #include "driverlib/gpio.h" #include "driverlib/debug.h" #include "driverlib/interrupt.h" #include "driverlib/rom.h" #include "driverlib/rom_map.h" #include "driverlib/pin_map.h" #include "driverlib/sysctl.h" #include "driverlib/i2c.h" #include "Wire.h" Here is a list of include files from Wire.cpp. So here is my question: is this Wire.cpp implementation is for TM4C? is it using or based on the TivaWare Peripheal library? I intend to make some modifications for it, for example using 2 i2c ports at the same time. So I need to start at the correct place. Any ideas / help greatly reccomended. Best regards, CA
  23. Pookie

    I2C Between 2 MSP430s

    Hello again, I am trying to connect up 2 MSP430FR4133 using the slave_sender and Master_reader examples in the energia given examples. There is no information about which pins to use but RXD and TXD are the only pins outputting on the scope so i have tried these pins. I have also tried connecting up the pins that say they are for SPI on the pin layout to no success. Any help would be greatly appreciated. Kind regards, Chris
  24. Hi, I just noticed an excessive consumption of ram by Wire on G2553 (I did not test on other µC) : 400 bytes !! I took a look at Wire.h but can't find where this memory is used. If anyone can confirm this and/or have an idea about this issue ? Regards
  25. So, this is partly for me, and partly for others who need a refresher, or just do not know how. But I will be making several post here over time on how to write very simply code, to do one thing, or another. These, used in conjunction with a shell script could be very useful / flexible. After several long talks with many people, including some here on these very forums. I've decided that using C, to communicate with hardware, or hardware interfaces is best as can be for many situations. However, when you need to run several tools all at once, and have output formatted in some fashion, or easily modified. Shell scripts are very good at that sort of thing. Read from a real-time clock This post I will make about reading from a real-time clock. I spent hours messing around code related to I2C communications, and could never get exactly what I wanted. Plus, I wanted something that output date / time that looked very similar to the date Linux command. This could definitely been done using a shell script, but code size would probably be a lot larger. Additionally, a shell script would very likely be a lot slower, as with a script, one would have to be calling external cmdline tools to perform various operations. This example code is very fast, and prints to screen immediately after issuing the command. Since this command is very simple, and only prints the formatted date / time to screen. This could very easily be called from a shell script, and formatted further if need be. The real-time clock I'm using for this demonstration is a Maxim DS3232 real-time clock which is very accurate, and also very expensive compared to other real-time clocks. At $7 + US each, it's not cheap. I also had to write my own device tree overlay for this RTC, which strictly speaking is not necessary. One can set the device up from the command line manually as demonstrated for many different RTC's on the web. In fact, all the device tree overlay that I wrote does, is set all this automatically up at boot. As far as teh actual overlay it's self. All I did was modify an existing overlay from the "official" bb-overlays repo on github. https://github.com/beagleboard/bb.org-overlays/blob/master/src/arm/BB-RTC-01-00A0.dts To look something like this: /* * Copyright (C) 2015 Robert Nelson <robertcnelson@gmail.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ /dts-v1/; /plugin/; #include <dt-bindings/board/am335x-bbw-bbb-base.h> #include <dt-bindings/gpio/gpio.h> #include <dt-bindings/pinctrl/am33xx.h> / { compatible = "ti,beaglebone", "ti,beaglebone-black", "ti,beaglebone-green"; /* identification */ part-number = "BB-RTC-01"; version = "00A0"; fragment@2 { target = <&i2c2>; __overlay__ { status = "okay"; /* shut up DTC warnings */ #address-cells = <1>; #size-cells = <0>; /* MCP79410 RTC module */ rtc@68 { compatible = "maxim,ds3232"; reg = <0x68>; }; }; }; }; On our cape, the RTC is on bus I2C-2, which is already enabled by default for capemgr. The rest of the above just means that status is okay(load the device ), the kernel module to load is called "ds3232", and the device address on the bus is 0x68. Now on to the actual C code for reading from /dev/rtc1: #include <stdio.h> #include <stdlib.h> #include <linux/rtc.h> #include <sys/ioctl.h> #include <sys/time.h> #include <sys/types.h> #include <fcntl.h> #include <unistd.h> #include <errno.h> void display_date_time(void) { struct rtc_time rtc_tm; int fd = open("/dev/rtc1", O_RDONLY); if(fd == -1){ perror("/dev/rtc"); exit(errno); } /* Read the RTC time/date */ int retval = ioctl(fd, RTC_RD_TIME, &rtc_tm); if (retval == -1) { perror("ioctl"); exit(errno); } int d = rtc_tm.tm_mday; int m = rtc_tm.tm_mon + 1; int y = rtc_tm.tm_year + 1900; const char *wdays[] = {"Sun","Mon","Tues","Wed","Thur","Fri","Sat"}; const char *mnths[] = {"Jan","Feb","Mar","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec"}; int wday = (d += m < 3 ? y-- : y - 2, 23*m/9 + d + 4 + y/4- y/100 + y/400)%7; fprintf(stdout, "%s %s %02d %02d:%02d:%02d %d UTC\n", wdays[wday], mnths[rtc_tm.tm_mon], rtc_tm.tm_mday, rtc_tm.tm_hour, rtc_tm.tm_min, rtc_tm.tm_sec, y); } int main( int argc, char **argv ) { display_date_time(); return 0; } As one can see, most of this code is for formatting the output in a specific way. In this case, the output will look exactly like the output one might expect to see after issuing the command "date". However, this output is fixed to output the date / time in the UTC time zone. As for one of the projects I'm using this in is for devices spread out all over the US, in 3 different time zones, and we do not care so much what the local time zone of that system so much, as much as knowing a given time "standard". e.g. if something fails, and we need to tell a customer what failed, and what time it failed, we can, Then if we need to convert that time to their time zone, easy. Notice that the read() is handled by ioctl(). . . Output: root@wgd:~/# gcc -Wall -o read_rtc read_rtc.c root@wgd:~/# ./read_rtc Tues May 09 23:08:49 2017 UTC