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.

CC2541 Register Problem

Other Parts Discussed in Thread: CC2541

Hi all,

I'm having problems setting the I2CDATA register in the CC2541 Keyfob. I've checked and I don't think that it's a mapping problem since I was able to read/write to the registers before it (0x6230 for I2CCFG and 0x6231 for I2CSTAT) and the ones after it (0x6233 - Own Slave Address  to 0x6235 - I2CIO) in a periodic function. I can read from I2CDATA fine which returns 0x00 since there's nothing there, but I can never seem to set it no matter what I do.

The documentation doesn't provide much information on it other than saying that it can't be accessed during byte shift operations and that it should be accessed during  an interrupt. I don't think any byte-shifting operations are being performed on it and I've tried raising an interrupt with an interrupt function using the I2C interrupt vector found in ioCC2541.h but I still can't seem to modify it so I'm frankly at a loss. Does anyone know if this register get automatically cleared upon being set or does it only get cleared after the I2C bus transmits the data through the pins? This thing is driving me nuts and I can't continue with work until I get this thing working. Any tips and suggestions would be great thanks!

Regards,

Noct

  • Hi Noct,

    Have you reviewed the example i2c implementation in the Sensor Tag project, hal_mag.c?

    Best wishes
  • Hi JXS,

    Thanks for the feedback,I've checked the examples and they all seem to be fairly straight forward. It turns out I can write to these registers and read from them but for some reason I can't see the changes in the IAR symbol/register viewers nor in the memory view at the location. I'm using IAR 8.30.2, is there perhaps something wrong with the C-SPY debugger itself?

    I've also checked with an Oscilloscope and I seem to be able to get an SDA line out from the pin but the signal is really noisy and I can't seem to get an SCL line signal at all. I think I might need to enable pullups for the pins but the I2CWC states that for I2C mode the settings has to be 0x00. Even if I enable SCLPUE and SDAPUE it wouldn't work since the OVR bit is set at 0 for I2C. According to the documentation if I set OVR to 1 it becomes GPIO.

    Regards,

    Noct
  • Hi Noct,

    Since you are using a non-supported IAR version for this release (8.20.2 is supported), you'll need to make adjustments to the linker config. Search the forum for details.

    Best wishes
  • Hi JXS,

    I'm afraid I haven't been able to find anything on linker configs except for compilation issues for IAR 8.30 which I haven't been having issues with due to using an advice from the forums linking to: supp.iar.com/Support;amp . There are other stuff about people wanting to custom-map their memory program but it doesn't seem relevant. Sorry to bother you but could you expand on what adjustments I need to make exactly?

    I also seem to be getting unwanted outputs from my SDA pin even without I2C enabled and transmitting on the oscilloscope, do you know if these pins are controlled by any other port registers or is it isolated to only the I2CIO and I2CWC registers? I'm using the Keyfob Demo as a base and the following code seems to worsen the unwanted outputs:

    // For keyfob board set GPIO pins into a power-optimized state
    // Note that there is still some leakage current from the buzzer,
    // accelerometer, LEDs, and buttons on the PCB.

    P0SEL = 0; // Configure Port 0 as GPIO
    P1SEL = 0x40; // Configure Port 1 as GPIO, except P1.6 for peripheral function for buzzer
    P2SEL = 0; // Configure Port 2 as GPIO

    P0DIR = 0xFC; // Port 0 pins P0.0 and P0.1 as input (buttons),
    // all others (P0.2-P0.7) as output
    P1DIR = 0xFF; // All port 1 pins (P1.0-P1.7) as output
    P2DIR = 0x1F; // All port 2 pins (P2.0-P2.4) as output

    P0 = 0x03; // All pins on port 0 to low except for P0.0 and P0.1 (buttons)
    P1 = 0; // All pins on port 1 to low
    P2 = 0; // All pins on port 2 to low

    If you could give me some directions here it'd be great thanks.

    Regards

    Noct
  • Hi Noct,

    The I2C lines are by default using a 20kOhm internal pull-up. This is usually not enough to ensure signal integrity in real life, so I would recommend adding external 10k or even 4.7k resistors for pull.

    What you are seeing as noise could be parasitic coupling with neighboring lines.

    In addition, I2C works in open-drain mode, meaning lines are driven low, but pulled up. Therefore, also make sure that the nodes are not tied or pulled to ground externally - I'm thinking here about your SCL line.

    To debug, consider using one of our eval kits like CC2541DK, or disconnect external I2C components on your board and verify that you get the expected result then.

    Best regards,
    Aslak

  • Hi Aslak,

    Thanks for the reply! I haven't got anything connected to the Keyfob at the moment as I'm only trying to verify whether there's output coming from the pins or not by attaching the pins to an oscilloscope. If that's the case with parasitic noise then there might really be nothing coming out of the SDA and SCL lines except for the noise from the neighboring pins. Would I still need the pull-up resistors to see the line changes or is it fine without them?

    Other than that I'm using the default ioCC2541.h library file provided by IAR along with the mapping schema in the .xcl and project configurations provided by TI so I don't think configuration would be a problem. I've also disabled power saving and I can read/write the registers fine (just can't see it in IAR for the case of I2CDATA). I'm not sure what else I might be missing on the software side of things.

    Regards,

    Noct
  • Hi,

    Without the pull-ups you can't be sure if a low signal is actually low. Are you sure you are measuring on the correct pins?

    I don't have a keyfob handy to test. Please verify that if you override the pins and use them for GPIO, you see changes in the measured signal level.

    BR,
    Aslak
  • Hi Aslak,

    I'm measuring pins 2 & 4 on the Test pin bus which correlates to SCL/SDA according to the data sheet. I'm setting the I2C override mode into GPIO by setting it to 0x83 so both pins are in GPIO output mode. I'm clearing and setting the I2CIO flags continuously in a periodic function but I don't seem to be getting any changes on the signal end of things nor do I see any changes from GND. It's still the same parasitic noise for the SDA line and nothing for the SCL line. I've posted my setup here:

    I'm using the LED as a GND source since it's the only one available. The Keyfob is powered by the Debugger.

    Possibly parasitic noise from other pins on SDA. This occurs even with the I2C Module disabled...

    The GND measurement:

    Regards,

    Noct