This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: Code Composer Studio
Hello,
I am trying to emulate 2 i2c slave devices with the TM4C123G. Basically I need to be able to receive i2c as slave in two adresses.
So from my rasberry pi which I have as the i2c master, I have connection to SCL2/SCL3 and SDA2/SDA3, and 10K pull up resistors, in place.
The following code partially works. i2cdetect will detect two devices at 0x40 and 0x42, but you can only write to 0x42 - and if you write to 0x40 it will crash. If the code is commented out to enable one i2c bus at one time, it will work for either i2c buses. I used 10K resistors, maybe that could be the problem.
But if there is a dual adress scheme for the tm4c it would be great, so i would not spend those extra pins.
Any ideas / help /recomendation greatly appreciated.
Best Regards,
C.A.
#include <Wire.h> void setup() { Wire.setModule(2); Wire.onReceive(receiveEvent2); Wire.begin(0x40); Wire.setModule(3); Wire.onReceive(receiveEvent3); Wire.begin(0x42); Serial.begin(230400); Serial.println("INIT"); } void loop() { } void receiveEvent2(int n) { Wire.setModule(2); Serial.print("2:\t"); while(0 < Wire.available()) { int c = Wire.read(); Serial.print(c); Serial.print('\t'); } Serial.println(); } void receiveEvent3(int n) { Wire.setModule(3); Serial.print("3:\t"); while(0 < Wire.available()) { int c = Wire.read(); Serial.print(c); Serial.print('\t'); } Serial.println(); }
Why do you consider 10K pull-up Rs a (potential) problem? (they prove far more effective than much higher value, MCU internal Rs.)
You've presented unique, "function calls only" (with ALL of the "code details "hidden"" - such proves (beyond) the abilities of most here (or likely anywhere) - to review & guide/comment.
You must realize that your, "actual" code IS required" (calling functions alone - prove w/out (much) value) - ("much" - to be kind...)
As an example - you call, "Wire.setModule(2);" How can anyone here "know" the "workings of that function? And the "correctness of your code implementation? Other than the "Serial.print()" - which we may be able to "guess" - myself/others - have NO CLUE!
Is it not your job - when seeking assistance here - to provide such (NEEDED) detail?
Greetings Charles,
Our poster made no mention of "energia" - it was entirely absent from poster's: Subject Line, Post's Body, and Tags.
I recall you past being, "reserved about "energia's use" (due to its limitations) - yet you (somehow) have (now) recognized poster's function calls as being, "energia-based."
As "energia" has its own, dedicated forum - and as poster made NO mention of "energia's exclusive use - "How could a "non-energia user" have "known" that "energia" was "in play?"
Might you advise such posters - when presenting issues & code (outside) of (the expected) "normal/customary" TM4C style & usage - that they should make (some) mention of their "special usage?" Had I had the slightest "hint" of energia - I would not have misspent time/effort...