Hi, I am planning to use the wm8904 codec(found on the lpcxpresso54628 board) with Nuttx.
I have the following problem: during the initial I2C setup of the wm8904, when trying to write to the 0x21 register, there is an indefinite stretch for the slave ACK. I attached the screenshots from the oscilloscope. The first one is with the start sequence which seems ok and the second one shows the failure. The 9th bit, the one for the slave ACK, stretches indefinitely. The SDA line seems to go up a bit, so I'm guessing that WM8904 does something. I don't understand why SCL doesn't go low. The I2C module reports a Start/Stop error and then goes to the idle state. I also tried the FreeRTOS example and it seems to work. I modified that example so that it would perform the same I2C writes and it still works. I checked to see if there are any differences between the I2C module init and I2C transfer function but I couldn't identify anything important. I also set up the MCLK and checked it with the oscilloscope and it is ok. Note that I mainly tested with I2C_POLLED but the problem seems to also appear on interrupt based transfers. Also, something that is bothering is that the behavior is a bit flaky. At first time it will fail to write reg 0x21, after a reset(SW1 button) it will fail to read the wm8904 id and after another reset it will again fail to write 0x21 and so on. Do you have any ideas or suggestions? Have you seen this behavior before? I also attached a patch for I2C, the I2C stop command wouldn't be sent for a write message. Best regards, Andrei Stefanescu
From db16ea8d9e487c50018b951614450dfeff53a730 Mon Sep 17 00:00:00 2001 From: Andrei Stefanescu <andr3i.stefane...@gmail.com> Date: Sun, 23 Feb 2020 13:52:15 +0200 Subject: [PATCH] lpc54xx: i2c: Ensure stop is sent for I2C transmit Previously, if we had a single message write transfer it would not have sent a STOP condition for the I2C bus. This patch modifies a bit the transfer end logic. Signed-off-by: Andrei Stefanescu <andr3i.stefane...@gmail.com> --- arch/arm/src/lpc54xx/lpc54_i2c_master.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/src/lpc54xx/lpc54_i2c_master.c b/arch/arm/src/lpc54xx/lpc54_i2c_master.c index 90cddbcd30..8881156ad8 100644 --- a/arch/arm/src/lpc54xx/lpc54_i2c_master.c +++ b/arch/arm/src/lpc54xx/lpc54_i2c_master.c @@ -662,10 +662,10 @@ static bool lpc54_i2c_statemachine(struct lpc54_i2cdev_s *priv) */ nextmsg = msg + 1; - dostop = ((nextmsg->flags & I2C_M_NOSTART) != 0); + dostop = ((nextmsg->flags & I2C_M_NOSTART) == 0); } - if (dostop) + if (!dostop) { /* Stop condition is omitted, we are done. Start the next * message (or return to the IDLE state if none). -- 2.17.1