The nRF51822-mKIT is a low cost ARM mbed enabled development board for Bluetooth® Smart designs with the nRF51822 SoC. The kit gives access to all GPIO pins via pin headers ...

Redbear BLE nano - rs232 stops working when using I2C

16 Oct 2014

Hello,

I try to use I2C on Redbearlab BLE Nano (nrf51822). When I add I2C object to my code, rs232 stops working. Please see sample code below:

#include "mbed.h"

DigitalOut myled(P0_19);
Serial  pc(P0_9, P0_11);
//I2C connection(P0_8, P0_10);

int main() 
{
    while(1) {
        myled = 1;
        wait(0.2);
        myled = 0;
        wait(0.2);
	
	pc.printf("Heartrate: %d\n", hrmCounter);
    }
}

If I2C is enabled there is no longer any output on rs232. LED keeps flashing. Is this a known bug? Or is there something wrong with this really simple code? I've also tried latest mbed source from git with the same result.

Regards, railwaycoder

16 Oct 2014

I've found out a strange behavior:

If I enable I2C and change the LED blinking speed, nothing happens to the LED blink speed. It is the same as before. There is no error during hex file upload.....

16 Oct 2014

I have to correct my last post, it is not the same blinking speed as before, it is completly different. It seems that device is back to facktory settings...

But from my thought this is not possible...?

18 Oct 2014

Debugging shows the following:

With I2C enabled, device hangs up in the mbed_die function. There the led from BLE nano is toggled.

WEAK void mbed_die(void) {
#ifndef NRF51_H
	__disable_irq();	// dont allow interrupts to disturb the flash pattern
#endif
#if   (DEVICE_ERROR_RED == 1)
    gpio_t led_red; gpio_init_out(&led_red, LED_RED);
#elif (DEVICE_ERROR_PATTERN == 1)
    gpio_t led_1; gpio_init_out(&led_1, LED1);
    gpio_t led_2; gpio_init_out(&led_2, LED2);
    gpio_t led_3; gpio_init_out(&led_3, LED3);
    gpio_t led_4; gpio_init_out(&led_4, LED4);
#endif

    while (1) {
#if   (DEVICE_ERROR_RED == 1)
        gpio_write(&led_red, 1);

#elif (DEVICE_ERROR_PATTERN == 1)
        gpio_write(&led_1, 1);
        gpio_write(&led_2, 0);
        gpio_write(&led_3, 0);
        gpio_write(&led_4, 1);
#endif

        wait_ms(150);

#if   (DEVICE_ERROR_RED == 1)
        gpio_write(&led_red, 0);

#elif (DEVICE_ERROR_PATTERN == 1)
        gpio_write(&led_1, 0);
        gpio_write(&led_2, 1);
        gpio_write(&led_3, 1);
        gpio_write(&led_4, 0);
#endif

        wait_ms(150);
    }
}
22 Oct 2014

Hi there,

you are using pins which are not currently supported, see the code below (pin definition) :

static const PinMap PinMap_I2C_SDA[] = {
    {p22, I2C_0, 1},
    {p13, I2C_1, 2},
    {NC, NC, 0}
};

static const PinMap PinMap_I2C_SCL[] = {
    {p20, I2C_0, 1},
    {p15, I2C_1, 2},
    {NC, NC,    0}
};

There is an issue on github https://github.com/mbedmicro/mbed/issues/573. The implementation should be changed, feel free to fix it and send a pull request.

Usually when it goes to mbed_die(), tehre is an error somewhere. Either assert or runtime error appeared. I would recommend in those situation checking pinout for used objects, if everything is as supported and then start looking at the application code .

Regards,
0xc0170

05 Nov 2014

Hi,

thanks, modifying the pins solves the problem. I2C works fine now. I really want to do this changes and contribute them, but I need to get some deeper understanding of mbed src first ;-)

Thanks and Best Regards,

railwaycoder

You need to log in to post a reply