I2C on wahoo with WICED SDK

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi Guys,

thanks to the platform files, I got my WICED firmware running on wahoo eval board pretty well I have taken the app "Wiced_sense" as template. But when trying to communicate with the accelerometer via I2C. and function:

CFA_BSC_STATUS cfa_bsc_OpExtended(UINT8* buf,

                         UINT16 bufCount,

                         UINT8* addr,

                         UINT8 addrCount,

                         UINT8 slaveAdr,

                         UINT8 operation);

is called all my LEDs Light for about a second, turn off and nothing works anymore.

Seems like I2C Pins were malconfigured, but I found no plays where to define them.

Or maybe more likely the lib isn't linked correctly and the program jumps to a totally wrong position. Actually I have not configured anything special concerning libs,


Since this function is the entry point to a lib, I cannot debug any further.

I would be very glad about some help.


Greetings,


Ruben

0 Likes
10 Replies
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

Hi,

The cfa library does function properly. In order to figure out what's going on we'll need more information. Where do you call cfa_bsc_OpExtended? And can you paste a sample of your call to it?

Also, can you describe the behavior in more detail? Up to what point you can get traces to print, and after how long the LED turns off.

Jacob

0 Likes
Anonymous
Not applicable

Here some additional Info:

- Im using WICED-Smart-SDK-2.2.1

- crashing call of cfa_bsc_OpExtended is within the "ReadReg" function in the  file lis3dsh_drive.c. (see below)

- call stack is:

    °wiced_sense_power_down_sensors (wiced_sense.c)

        °(SetAxis(X_DISABLE | Y_DISABLE | Z_DISABLE)  (wiced_sense.c)

              °ReadReg (lis3dsh_drive) ...

- ReadReg crashes also when called from other functions


- crashing call of cfa_bsc_OpExtended is defined in cfa.h but I cannot find any implementation of this function.


- All User LEDs (GPIO PINs 11,13,14) light for 2-3seconds then go off and interrupt of my button doesn't work anymore and I cannot connect to device And source code below is not performed anymore -> seems like Code jumps to wrong Spot !


              

For my understanding I have the following questions:

1) Where is cfa_bsc_OpExtended defined / implemented (searching with notepad besides function calls I found some entries in \Wiced Smart\tier2\brcm\libraries\ lib\20736\a4wp_hal_api.a and ...tier2\brcm\mandatory\bld\20736\patch.elf

-> Maybe code isn't linked at all ?

2) Where are I2C Pins defined ? Can it be used on wahoos GPIOs at all (Im trying to get accelerometer running)

3) Is it possible to get remote debugging running on wahoo board with WICED SDK ?

And if how ?

/*******************************************************************************

* Function Name : ReadReg

* Description : Generic Reading function. It must be fullfilled with either

* : I2C or SPI reading functions

* Input : Register Address

* Output : Data Read

* Return : None

*******************************************************************************/

u8_t ReadReg(u8_t deviceAddr, u8_t Reg, u8_t* Data) {

  CFA_BSC_STATUS read_status;

  read_status = cfa_bsc_OpExtended(Data, sizeof(u8_t), &Reg, sizeof(u8_t), deviceAddr, I2C_SLAVE_OPERATION_READ);

    switch(read_status)

    {

        case CFA_BSC_STATUS_INCOMPLETE:

            // Transaction did not go through. ERROR. Handle this case.

        return MEMS_ERROR;

            break;

        case CFA_BSC_STATUS_SUCCESS:

            // The read was successful.

        return MEMS_SUCCESS;

            break;

        case CFA_BSC_STATUS_NO_ACK:

            // No slave device with this address exists on the I2C bus. ERROR. Handle this.

        default:

            break;

    }

    return MEMS_ERROR;

}

0 Likes
Anonymous
Not applicable

Addemdum to my Question 1)

I guess this code must be in cfa library but where is it and how can I make sure it is existing and properly linked ?

Many thanks in advance 🙂

I'm keen to get the accelerometer running.

0 Likes
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

I believe the problem is with your addressing.

Please go into lis3dsh_driver.h and change:

#define MEMS_I2C_ADDRESS 0x3C  //SEL=1


to:


#define MEMS_I2C_ADDRESS 0x3E

Taking a look at the differences in the schematics between WICED Sense and Wahoo, you'll notice that in the SD0 pins are pulled low and high respectively. This means that you must toggle the value of the 7th bit to properly address the device. Why the code crashes must have something to do with your firmware sitting in a loop after failing. But the failed reads/writes are likely due to incorrect addressing.

If you still have trouble, I will send you a sample app tomorrow to test on your board.

Jacob

ndutton

0 Likes
Anonymous
Not applicable

Hi Jacob,

thanks for the quick answer

unfortunately it still doesn't work changing MEMS_I2C_ADDRESS to 0x3E

But moving the crashing function call to the "wiced_sense_fine_timeout" I found out that the all LEDs blinking was just a coincidence.

My code just stops at the moment this function is called and all Outputs then stuck for about a 2-3 seconds and then all Outputs are driven low and nothing works anymore..

But are you sure this can be an adressing issue ? Since No ACK should be captured in the ReadReg function(see my previous post):

        case CFA_BSC_STATUS_NO_ACK:

            // No slave device with this address exists on the I2C bus. ERROR. Handle this.

Maybe your example code can give me a hint when it is running successfully.


PS: Is there an answer to my questions 1-3 ? That might get me further ....

Many thanks and greetings,

Ruben

0 Likes
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

Unfortunately, on taking a closer look at the Wahoo schematic, the accelerometers appear to be different all together. Although the model numbers vary by only the last letter, it appears as though they have two different datasheets. You won't be able to use any of the wiced_sense drivers for this. You'll have to implement the functionality yourself.

Since I don't have the sensor to test, I can't attach a sample app.

Here's the datasheet: http://www.st.com/web/en/resource/technical/document/datasheet/CD00274221.pdf

Your new address is going to be 0x32.

A quick read of the WHO_AM_I register would look like the code below. Paste this into the timeout function of any sample app and run traces on it and you should see decimal value 51 printed out according to the datasheet (page 26).

#define I2C_SLAVE_OPERATION_READ                    (0)

#define I2C_SLAVE_OPERATION_WRITE                   (1)

{

UINT8 WHO_AM_I_REG = 0x0F;

UINT8 * Data;

cfa_bsc_OpExtended(Data, sizeof(u8_t), &WHO_AM_I_REG, sizeof(u8_t), 0x32, I2C_SLAVE_OPERATION_READ);

ble_trace1("WHO_AM_I:  %6d", *Data);

}

Jacob

0 Likes

ruma89

Since this is a Zentri (formerly ACKme Networks) evaluation board with sensors they have selected and support, you may want to open a ticket on their site directly and ask for support: Zentri

ndutton

0 Likes
Anonymous
Not applicable

Alright, I opened a Ticket at Zentri.

Unfortunately I could not read WHO AM I reg with the code you posted. Same behavior as before

But Maybe you can tell me how to use debug traces on wahoo. Or is this also not possible ?

Didn't get it running by now ...

Many thanks,

Ruben

0 Likes
Anonymous
Not applicable

Hey Guys,

putting UART switch to USER, so that no programming mode is entered, and using cfa function you posted on every 7th finetimout (green LED blinking 4 times) I find my board in a boot loop.

// Fine timer timeout.

void wiced_sense_fine_timeout(UINT32 arg)

{

    // ... green LED Blinking code (not posted to save lines)

 

     UINT8 WHO_AM_I_REG = 0x0F;

    UINT8 buf[10];

  if (TestCntr == 7)

  {

  // Following Line Leads to reset ! Since green LED keeps it's state for about 1,2 seconds program is likely to hang in a timeout before reset

  cfa_bsc_OpExtended(buf, sizeof(u8_t), &WHO_AM_I_REG, sizeof(u8_t), 0x32, I2C_SLAVE_OPERATION_READ);

  //Light blue LED  not performed any more !

  gpio_setPinOutput( GPIO_PIN_LED_B/ 16, GPIO_PIN_LED_B, TRUE);

  }

  TestCntr++;

}

I guess tomorrow I wil take my evalboard to work and solder some wires to GPIO pads of I2C and see if communication is done properly ..

Can you please answer me 3 questions :

1) Unfortunately I cannot find wiced sense schematic. could you give me a link ?

2) basically should I be possible to use cfa on wahoo? and what about those lines regarding AMS00x/wahoo ?

// Also RSA code requires a bit larger data size than default 264 bytes.

cfa_mm_ConfigureMemoryPool(CFA_MM_POOL_2, 272, 10);

3) basically should I be possible to use debug trace ? didn't get it running

Many thanks & greetings,

- Basically cfa should be usable for wahoo ?

Ruben

0 Likes

For item 1: WICED Sense Reference Design Schematic (PDF)

I think 2 and 3 need to be answered by ACKme/Zentri.

Debug trace works on our development board and WICED Sense (there is a menu within the SDK).

0 Likes