Jump to content
Sign in to follow this  
vim505

Troubles with I2C on a EK-TM4C1294XL connected Lauchpad

Recommended Posts

Hi,

 

I am trying to get i2c working on a EK-TM4C1294XL on energia. I am trying to use i2c channel 0. So they should be on pb2 and pb3. Thing is, I do not see any signal on sda or sck on the scope except for the pullup.

 

On the serial debug I see "Start" and "Loop" but "Loop2" never appears. Like it is stuck sending I2c. As simpel as this program is, I am not getting it or something is wrong in the libraries.

 

Hope you can help,

 

cheers

 

John

#include <Wire.h>


void setup()
{
  Wire.setModule(0);
  Wire.begin();                // join i2c bus (address optional for master)
  Wire.setModule(0);
  Serial.begin(115200);          // start serial communication at 9600bps
  pinMode(PC_7, OUTPUT);
  pinMode(PB_2, INPUT_PULLUP);
  pinMode(PB_3, INPUT_PULLUP);
  Serial.println("Start");
}


void loop()
{
  Serial.println("Loop");
  
 
Wire.beginTransmission(112); // transmit to device #112 (0x70)
  Wire.write(byte(0x00));      // sets register pointer to the command register (0x00)  
  Wire.write(byte(0x50));      // command sensor to measure in "inches" (0x50) 
  Wire.endTransmission();      // stop transmitting


  Serial.println("Loop2");


  digitalWrite(PC_7,HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(250);                  // wait a bit since people have to read the output :)
  digitalWrite(PC_7, LOW);    // turn the LED off by making the voltage LOW
  delay(250);                  // wait a bit since people have to read the output :)
}

Share this post


Link to post
Share on other sites

I2C is a particularly picky protocol. Double, then triple check that your hardware is wired up correctly. Pullups, and swapping SDA/SCL are some of the more common problems that can occur.

 

On the software side of things, what you have should work (assuming hardware is fine, bu dunno about the setModule functions), with one thing to note. I don't know if the begimTransmission function takes in the 7 bit address, and expects you to shift it or not. It's the difference between 0x70 and 0x38.

Share this post


Link to post
Share on other sites

Hi Mr Cruz,

 

I2c is not that tricky, I have done a lot of i2c on arduino, thing is the TM4C1294 has 8 separate I2c channels. So you have to tell energia what chanel to use. For this you use the setmodule command. Then you tell the master start communicating with the slave. The master starts by putting a clock and an adress on the sda and scl lines. And here is my problem on my oscciloscope I cannot see these signals, further more the software hangs trying to execute these commands. 

 

That brings me to the conclusion that there is something wrong inside the libraries. I am fully aware that things are somewhat new, but a basic I2C function should work in a release of energia. I don't want to start bitbanging when I have hardware I2c Fifo's. We should be going forward not back.

 

cheers

 

John

Share this post


Link to post
Share on other sites

That launchpad doesn't have internal pull-ups in the I2C operation mode. you need external resistors for that. 

By doing pinMode(PB_2,INPUT_PULLUP); you are un-configuring the pin from I2C mode.

Also, you should do setModule before Wire.begin only

Share this post


Link to post
Share on other sites

Hi guys,

 

I cannot communicate through I2C(0) (PB_2,PB_3) to a magnetic sensor  AS5048B from AMS (Austrian microsystems). I only get 0.00 even if a disconnect the sensor. I am using the EK-TM4C129XL board. The sensors is mounted on a PCB, (10k pull ups on board). Pins A1 and A2 are connected to ground therefore the sensor Address is 0x40. With an Arduino DUE the AS4048B works fine. For this sensor there is a library available (ams_as5048b.h from SOSAndroid.f).

 

My code:

 

#include <Wire.h>
#include <ams_as5048b.h>
 
unsigned int timeSystem = 0;
unsigned int timeEncoder = 0;
 
AMS_AS5048B mysensor;
double enc = 0;
 
void setup()
{
  Wire.setModule(0);
  Wire.begin(0);
 
  Serial.begin(115200);
}
 
void loop()
{
  timeSystem = millis();
  if(timeSystem - timeEncoder > 1000)
  {
    timeEncoder = timeSystem;
    mysensor.updateMovingAvgExp();
    Serial.println(mysensor.angleR(U_RAW, true));
    Serial.println(mysensor.angleR(U_DEG, false));
  }
}
 
The library ams_as5048b is available at https://github.com/sosandroid/AMS_AS5048B
 
from ams_as5048b.h i have deactivate lines:
58 //#define SERIAL_DEBUG_ENABLED
59 //#define USE_WIREBEGIN_ENABLED // to comment if Wire.begin() function is called in Setup() for instance. Usefull to manage one or several I2C devices in the same sketch
 
those lines disable in void AMS_AS5048B::begin(void)
 
#ifdef USE_WIREBEGIN_ENABLED
Wire.begin();
#endif
#ifdef SERIAL_DEBUG_ENABLED
_debugFlag = true;
if (!Serial) {
Serial.begin(9600);
}
#endif
 
i have studied the hole library and the following methods seem to be ok
 
uint8_t   readReg8(uint8_t address);
uint16_t readReg16(uint8_t address); //16 bit value got from 2x8bits registers (7..0 MSB + 5..0 LSB) => 14 bits value
void       writeReg(uint8_t address, uint8_t value);
 
I would appreciate any advice to solve this issue.
 
Thanks in advance.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...