I2C in Beacon Reference Design

8 posts / 0 new
Last post
Krutarth
Offline
Last seen:5 years 1 week ago
加入:2015-07-09 19:57
I2C in Beacon Reference Design

Hi,
I want to use a Sensor with I2C interface along with the beacon. I am working with Beacon reference design as my starting point. Although whenever i try to configure pins for i2c bus the beacon stops advertising for unknown reasons. The only change that i have made in the Beacon Reference design is in the periph_setup.c in the function set_pad where peripheral pins are assigned for beacon reference design. The changes made are:
//Code Snippet start
void set_pad_functions(void) // set gpio port function mode
{

#if (CFG_HW_CONFIG == HW_CONFIG_SMARTTAG)
GPIO_ConfigurePin( GPIO_PORT_1, GPIO_PIN_4, INPUT_PULLDOWN, PID_GPIO, false );
GPIO_ConfigurePin( GPIO_PORT_0, GPIO_PIN_6, OUTPUT, PID_GPIO, false );
GPIO_ConfigurePin( GPIO_PORT_0, GPIO_PIN_5, INPUT, PID_GPIO, false);
if (!sys_startup_flag)
GPIO_ConfigurePin( GPIO_PORT_1, GPIO_PIN_5, OUTPUT, PID_GPIO, false); // GREEN LED OFF TO REDUCE POWER CONSUMPTION

GPIO_ConfigurePin (GPIO_PORT_0 GPIO_PIN_0, INPUT_PULLUP, PID_GPIO, false);
GPIO_ConfigurePin( GPIO_PORT_0, GPIO_PIN_3, INPUT_PULLUP, PID_GPIO, false);
GPIO_ConfigurePin( GPIO_PORT_0, GPIO_PIN_1, INPUT_PULLUP, PID_GPIO, false);
GPIO_ConfigurePin( GPIO_PORT_0, GPIO_PIN_2, INPUT_PULLUP, PID_GPIO, false);
#elif (CFG_HW_CONFIG == HW_CONFIG_DK)
GPIO_ConfigurePin( GPIO_PORT_1, GPIO_PIN_1, INPUT_PULLUP, PID_GPIO, false); // PUSH_BUTTON
#elif (CFG_HW_CONFIG == HW_CONFIG_PVCELL)
GPIO_ConfigurePin (GPIO_PORT_0 GPIO_PIN_0, INPUT_PULLDOWN, PID_GPIO, false );
GPIO_ConfigurePin( GPIO_PORT_0, GPIO_PIN_3, INPUT_PULLDOWN, PID_GPIO, false );
#elif (CFG_HW_CONFIG == HW_CONFIG_SMARTTAG2)

GPIO_ConfigurePin( GPIO_PORT_0, GPIO_PIN_1, OUTPUT, PID_GPIO, false); // BUZZER-
GPIO_ConfigurePin( GPIO_PORT_1, GPIO_PIN_0, OUTPUT, PID_GPIO, false); // BUZZER+
GPIO_ConfigurePin( GPIO_PORT_1, GPIO_PIN_1, INPUT_PULLDOWN, PID_GPIO, false); // PUSH_BUTTON
GPIO_ConfigurePin( GPIO_PORT_0, GPIO_PIN_2, OUTPUT, PID_GPIO, false); // LED

GPIO_ConfigurePin( SPI_GPIO_PORT, SPI_CS_PIN, OUTPUT, PID_SPI_EN, true );
GPIO_ConfigurePin( SPI_GPIO_PORT, SPI_CLK_PIN, OUTPUT, PID_SPI_CLK, false );
GPIO_ConfigurePin( SPI_GPIO_PORT, SPI_DO_PIN, OUTPUT, PID_SPI_DO, false );
GPIO_ConfigurePin (SPI_GPIO_PORT SPI_DI_PIN INPUT, PID_SPI_DI, false );

GPIO_ConfigurePin( GPIO_PORT_0, GPIO_PIN_7, OUTPUT, PID_GPIO, false); // SPI_PE

#elif (CFG_HW_CONFIG == HW_CONFIG_BEACON_REF)
#ifdef CFG_SPI_FLASH
GPIO_ConfigurePin( SPI_GPIO_PORT, SPI_CS_PIN, OUTPUT, PID_SPI_EN, true );
GPIO_ConfigurePin( SPI_GPIO_PORT, SPI_CLK_PIN, OUTPUT, PID_SPI_CLK, false );
GPIO_ConfigurePin( SPI_GPIO_PORT, SPI_DO_PIN, OUTPUT, PID_SPI_DO, false );
GPIO_ConfigurePin (SPI_GPIO_PORT SPI_DI_PIN INPUT, PID_SPI_DI, false );
#endif

GPIO_ConfigurePin(I2C_GPIO_PORT, I2C_SCL_PIN, INPUT, PID_I2C_SCL, false);/////This are the new lines i have added
GPIO_ConfigurePin(I2C_GPIO_PORT, I2C_SDA_PIN, INPUT, PID_I2C_SDA,false);/////This are the new lines i have added
#endif
}
//code snippet end

And yes I have defined I2C_GPIO_PORT as Port 0, I2C_SCL_PIN as P0.6 and I2C_SDA_PIN as P0.7, So why does the beacon stop advertising when these two lines are added ? Is there a way to use I2C drivers with Beacon Reference design?

Thanks and Regards,

MT_dialog
Offline
Last seen:1 month 2 weeks ago
Staff
加入:2015-06-08 11:34
Hi Krutarth,

Hi Krutarth,

Please check the various configurations for the Beacon reference design, maybe there's a confilict somewhere, it depends on your hardware configuration. And have you reserved the GPIO pins before using it? This will give a clue if there is a conflict.

Thanks MT_dialog

Krutarth
Offline
Last seen:5 years 1 week ago
加入:2015-07-09 19:57
Thanks for the advice MT

Thanks for the advice MT_Dialog. I tried reserving GPIO pins where i am a bit confused. If you can clarify my confusion that will help a lot. When I write these lines for reserving GPIO
//Code Snippet Start
RESERVE_GPIO( SPI_CLK, I2C_GPIO_PORT, I2C_SCL_PIN, PID_I2C_SCL);
RESERVE_GPIO( SPI_DI, I2C_GPIO_PORT, I2C_SDA_PIN, PID_I2C_SDA);
//Code Snippet Ends
The code works fine but if i make these changes as shown below it stops working, I don't know why.
//Code Snippets Start
RESERVE_GPIO( I2C_SCL, I2C_GPIO_PORT, I2C_SCL_PIN, PID_I2C_SCL);
RESERVE_GPIO( I2C_SDA, I2C_GPIO_PORT, I2C_SDA_PIN, PID_I2C_SDA);
//Code Snippet ends

Also i am using I2C bus does using defined constants SPI_CLK and SPI_DI make a difference?Please guide me through this.

Thanks and Regards,

MT_dialog
Offline
Last seen:1 month 2 weeks ago
Staff
加入:2015-06-08 11:34
Hi Krutarth,

Hi Krutarth,

As far as i know this should not make any difference, the name parameter in the RESERVE_GPIO is just a name and doesn't have any function in the macro RESERVE_GPIO. What you are mentioning sounds very weird.

Thanks MT_dialog

Krutarth
Offline
Last seen:5 years 1 week ago
加入:2015-07-09 19:57
I am sorry there was another

I am sorry there was another part of code that was creating the problem it was
//Code Snippet start
WAIT_UNTIL_I2C_FIFO_IS_EMPTY();
//Code Snippet end
Right now i am using PAN1740 evaluation kit and no I2C device is on the bus. So if this macro is called will it end into a endless waiting loop? Can i use I2C without using this macro?I was planning to have the device connected after i was done with firmware.

Thanks and Regards,

MT_dialog
Offline
Last seen:1 month 2 weeks ago
Staff
加入:2015-06-08 11:34
Hi krutarth,

Hi krutarth,

Yes this macro will end in an endless while loop. We cant tell for sure what will happen if you just remove it, you should use the driver as is and test your firmware.

Thanks MT_dialog

Krutarth
Offline
Last seen:5 years 1 week ago
加入:2015-07-09 19:57
Hi Dialog,

Hi Dialog,
I have been trying to use the drivers provided by SDK to read temperature data from the sensor using I2C. The temperature data is of 2 bytes and is stored at a single address 0x00 i have trouble reading the second byte since all the functions in the driver provided by you guys read a single byte after sending address. The temperature sensor sends 2 bytes of data for the single address. Can you please tell me a solution to reading two bytes of data continuously for single address.

Thanks and Regards,

Krutarth
Offline
Last seen:5 years 1 week ago
加入:2015-07-09 19:57
Close this ticket the issue

Close this ticket the issue has been solved in another thread.

Thanks and Regards,

Topic locked