Using I2C extern
응답
15. 8. 5 오전 10:24
Hello,

Has anyone tried to implement additional sensors to the XDK via I2C bus? How to configure the I2C channel 1 with default pins PB11 and PB12? Without other configuration, the function I2C_busWriteChannel1(...) after I2C_drvInit(...) runs infinite without output on pins.

Thanks,

Jürgen
 
0 (0 투표)
Using I2C extern
응답
15. 8. 6 오후 12:44 as a reply to Jürgen Schuster.
Hello Jürgen,
i fixed your Problem. To use the I2C channel 1 with PB11 and PB12 you have to do the following three things:

1.In the file C:\XDK-Workbench\SDK\platform\core\uC\I2C\SID\EFM32\I2C_efm32Driver_cc.c the location for the I2C channel 1 gets initialized to 3 but for channel 1 to appear at PB11 / PB12 the lochation has to be at 1
Change the init- code to
I2C1 ->ROUTE = I2C_ROUTE_SDAPEN | I2C_ROUTE_SCLPEN | (1 << 8 )

2.In the same file there is a conditional #ifdef CPPUTEST in the function I2C1_IRQHandler () which disables the build of the funcionality of the handler.
Change the Macro to #ifndef CPPUTEST

3.The mode of the pins is P11 and P12 is disabled ( 0 ) when entering the run() function
In the init- function of your application read the value of the memory location at adress 0x400602c ( GPIO_PB_MODEH) in a temporary 32bit variable, do a or combination with 0x00088000 ( PB11 and PB12 as open drain) and write the result back to the address.

This should do the job.

Regards
 
0 (0 투표)
Using I2C extern
응답
15. 8. 7 오전 10:13 as a reply to Klaus Nagel.
Yes, it works!
Thank you  very much for the quick help. I think this bugfix is interesting for BCDS, too.

Bye,

Jürgen
 
0 (0 투표)
Using I2C extern
응답
15. 8. 7 오후 12:56 as a reply to Jürgen Schuster.
Hi Jürgen and nagelkl,

I've been monitoring this thread and been discussing with our second level support how we can share this the best for the community. 
I'll follow up with an update soon.

- Florian
0 (0 투표)
Using I2C extern
응답
15. 8. 17 오전 7:46 as a reply to Florian Harr.
Hello Jürgen,


after checking back with our development team, the issue your have described has been fixed in XDK Workbench v1.3.0.

Could you please check (Help -> About), which version of XDK Workbench you are using? In case you are not using the latest version, please use the online update to get the latest version.


Regards

Bastian
0 (0 투표)
Using I2C extern
응답
15. 8. 17 오전 7:48 as a reply to Wolf-Bastian Pöttner.
Hello again,


instructions for setting up the online update inside the Bosch network can be found here:
https://xdk.bosch-connectivity.com/webdav/bcdscommunitygb/document_library/XDK_Downloads/Documentation/XDK_Workbench_Update_v1.pdf


Bastian
0 (0 투표)
Using I2C extern
응답
15. 8. 20 오전 11:12 as a reply to Wolf-Bastian Pöttner.
Hello,
Instead of XDK's BMA280 sensor I am currently trying to interface an external BMA280 sensor (which is connected with pull-up resistors and capacitors as per data sheet) via I2C using "Demo: XDK Data Logger" as my base program. Kindly help me to know what are changes required in the coding to interface via I2C (PB11 - SDA and PB12 - SCL)

Regards
Siva
0 (0 투표)
Using I2C extern
응답
15. 8. 21 오전 4:44 as a reply to Sivaprakash Sivamani.
Hello Siva,
have you tried the steps i described earlier in this thread?

Regards

Klaus
 
0 (0 투표)
Using I2C extern
응답
15. 8. 21 오전 8:52 as a reply to Klaus Nagel.
Hi Klaus,
Thanks for your reply, I had applied step 1 and 2 in  "Demo XDK Data Logger" file based on your thread but am not sure how to apply step 3 so could you please elaborate.

Regards
Siva
0 (0 투표)
Using I2C extern
응답
15. 8. 21 오전 9:02 as a reply to Sivaprakash Sivamani.
Hi Siva,
in the function SSU_initSystem i added the following code:

uint32_t *pportbmode = (uint32_t*)0x4000602c;
// Set the Mode for PB11 an PB12 to Open Drain
uint32_t temp = *pportbmode;
temp |= 0x00088000;
*pportbmode = temp;
This sets the mode of thePB11 and PB12 to Open Drain

Regards

Klaus
 
0 (0 투표)
Using I2C extern
응답
15. 8. 21 오전 9:14 as a reply to Klaus Nagel.
Hi Klaus,
I have added the following code but still it is reading the value from XDK's inbuilt BMA280 sensor and not from my external BMA280 sensor


Regards
Siva
0 (0 투표)
Using I2C extern
응답
15. 8. 21 오전 9:14 as a reply to Sivaprakash Sivamani.
Hi Klaus,
I have added the following code but still it is reading the value from XDK's inbuilt BMA280 sensor and not from my external BMA280 sensor


Regards
Siva
0 (0 투표)
Using I2C extern
응답
15. 8. 25 오후 12:28 as a reply to Sivaprakash Sivamani.
Hi Klaus,
Thanks for your support.


Regards
Siva
0 (0 투표)
Using I2C extern
응답
15. 9. 8 오전 8:08 as a reply to Sivaprakash Sivamani.
Hi Siva,

I am currently working on i2c for interfacing sensors. Could you please give me your Linkedin (facebook) profile so that I can share my knowledge and get some inputs from you.
Thank you,

Regards,
Sarathkumar.
0 (0 투표)
Using I2C extern
응답
15. 9. 8 오전 8:29 as a reply to Sarathkumar karunakaran.
Hi Sarath,
Glad to meet you!... if you required any support or guidance based on what I did kindly contact me through fixed-term.Sivamani.Sivaprakash@uk.bosch.com


Regards,
Siva
0 (0 투표)
Using I2C extern
응답
15. 10. 27 오후 1:20 as a reply to Sivaprakash Sivamani.
Hi,

has anybody already tried to read the data via the extension board I2C pins apart from the XDK sensors inbuilted  and maybe can provide an example code? 

Regards,
Sarathkumar

 
0 (0 투표)
Using I2C extern
응답
15. 10. 27 오후 2:30 as a reply to Sarathkumar karunakaran.
Hi Sarathkumar,

Here is our code to read out up to eight LM75 temperature sensors:

static void initI2C()
{
 // Set the mode for PB11 an PB12 to open drain
 uint32_t *pportbmode = (uint32_t*)0x4000602c;
 uint32_t temp = *pportbmode;
 temp |= 0x00088000;
 *pportbmode = temp;
 // Initialize I2C channel 1
    I2C_drvInit(I2C_CHANNEL_1,  1<<8);
    // make additional GND at pin E2
 GPIO_handleInfo_t gnd;
    gnd.port = gpioPortE;
    gnd.bitIndex = 2;
    gnd.magicWord = GPIO_HANDLE_MAGIC_WORD;
    GPIO_init(&gnd, GPIO_DIRECTION_OUTPUT, GPIO_STATE_OFF);
}

static int readTemperatures(char *str)
{
 int count = 0;
 for (int i = 0; i < NUM_ADDRESS; i++)
 {
  unsigned char address = addresses[i];
  int8_t buffer[2];
  if (i == 0) str[0] = '\0';
  else strcat(str, ";");
  if (I2C_busReadChannel1(address, 0, (unsigned char*)&buffer, 2) == 0)
  {
   char s[7];
   if (buffer[1] & 0x80) sprintf(s, "%d.5", buffer[0]);
   else sprintf(s, "%d", buffer[0]);
   strcat(str, s);
   count++;
  }
 }
 return count;
}

I hope it helps you!

Greetings,

Jürgen
 

0 (0 투표)
Using I2C extern
응답
15. 11. 27 오후 12:51 as a reply to Jürgen Schuster.
Hi Jürgen,

thanks for the code sample, this is similar to what was posted before about how to use external I2C interfaces.

I've used and adopted your code to get it working with a couple of other sensors.

We should definitely conserve your post so other users will be able to see this without searching too deep in the community. - I'll make sure this will happen.

- Florian
0 (0 투표)
RE: Using I2C extern
응답
19. 2. 10 오후 1:22 as a reply to Florian Harr.

Hi,

I am using the example "XDKExtensionPort" in WB 3.4 ,with Grid-EYE sensor, but i am not getting any output in the console. I tried to keep some print statement but they are also not giving any output.

Please tell me a solution.

Thank you,

0 (0 투표)
RE: Using I2C extern
응답
19. 8. 15 오전 9:23 as a reply to AnanthaChakravarthi Immadi.

Hello,

you can also use Mita to see how the I2C works, here is an short example regards the Grid-Eye sensor:

 

/**
 * Welcome to Eclipse Mita.
 *
 * Not sure what to do now?
 * Check out the "Getting started" guide in the Eclipse help.
 */

/*
 * The Panasonic Grideye is a 8x8 thermal imaging sensor. It can be accessed via I2C.
 */

package main;
import platforms.xdk110;

setup XDK110 {
	applicationName = "GridEyeDemo";
}

setup net : WLAN {
	ssid = "yournet";
	authentification = Personal(psk = "secretkey");

}

setup backend : MQTT {
	transport = net;
	url = "mqtt://192.168.xxx.xxx";
	clientId = "xdk";
	var r = topic("grideye");
}

setup gridEye : I2C {
	deviceAddress = 0x68;
	var powerControl = register_uint8(address = 0x00);
	var framerate = register_uint8(address = 0x02);
	var thermistor = register_int16(address = 0x0E);
	var temperatures = array_register_int16(address = 0x80, length=64);
}

setup hmi : LED {
	var left = light_up(color = Yellow);
	var right = light_up(color=Red);
}
 
every XDK110.startup {
	gridEye.powerControl.write(0x00);
	gridEye.framerate.write(0);
	
} 


let threshhold = 30;
struct state {
	var inUse : bool;
	var inUseLastTime : bool;
	var count : uint32;	
}

var sLeft = state(false, false, 0);
var sRight = state(false, false, 0);

every 1 second {
	var temps = gridEye.temperatures.read();
	
	hmi.left.write(false);
	hmi.right.write(false);
	
	sLeft.inUseLastTime = sLeft.inUse;
	sLeft.inUse = false;
	
	sRight.inUseLastTime = sLeft.inUse;
	sRight.inUse = false;
	
	var strBuf : string = new string(500);
	
	for(var i = 0; i < 8; i++) {
		for(var j = 0; j < 8; j++) {
			let tRaw = temps[i*8 + j];
			let t : float = tRaw / 4.0f;
			print(`${t} `);
			if(t > threshhold) {
				var s = &sRight;
				if(j >= 5) {
					s = &sLeft;
					hmi.left.write(true);
				}
				else if(j <= 2) {
					hmi.right.write(true);
				}
				
				if(!(*s).inUse && (j <= 2 || j >= 5)) {
					(*s).inUse = true;
					if(!(*s).inUseLastTime) {
						(*s).count++;
					}
				}
			}
			strBuf += `${tRaw}`;
			if(j != 7) {
				strBuf += ",";
			}
		}
		if(i != 7) {
			strBuf += ",\n";
		}
		println("");
	}
	println(`Left: ${sLeft.count} | Right: ${sRight.count}`);
	//println(strBuf);
	println("");
	
	backend.r.write(`{"data": [${strBuf}], "left": ${sLeft.count}, "right": ${sRight.count}}`);
	println("done");
}
0 (0 투표)