From 94204bd3bd8ca9e2dc45cafecfcc2e63acff3b61 Mon Sep 17 00:00:00 2001 From: guido Date: Sun, 30 May 2021 18:27:14 +0200 Subject: [PATCH] Fix I2C communication issue with MCP23008, where STOP-condition was failing due to SDA non-LOW possibly because of a late ACK. --- QCX-SSB.ino | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/QCX-SSB.ino b/QCX-SSB.ino index 54fa135..5a40719 100644 --- a/QCX-SSB.ino +++ b/QCX-SSB.ino @@ -1115,6 +1115,8 @@ ISR(PCINT2_vect){ // Interrupt on rotary encoder turn enc.event(); }*/ +// I2C communication starts with a START condition, multiple single byte-transfers (MSB first) followed by an ACK/NACK and stops with a STOP condition; +// during data-transfer SDA may only change when SCL is LOW, during a START/STOP condition SCL is HIGH and SDA goes DOWN for a START and UP for a STOP. class I2C { public: #if(F_MCU > 20900000) @@ -1194,10 +1196,11 @@ public: SendBit(data, 1 << 2); SendBit(data, 1 << 1); SendBit(data, 1 << 0); - I2C_SDA_HI(); // recv ACK + SendBit( 0, 1 << 0); // ACK/NAK: instead of assuming slave will set SDA is LOW (ACK), force SDA is LOW so that at least STOP condition will succeed (in case ACK is delayed, e.g. with MCP23008). + /*I2C_SDA_HI(); // recv ACK DELAY(I2C_DELAY); I2C_SCL_HI(); - I2C_SCL_LO(); + I2C_SCL_LO();*/ } inline uint8_t RecvBit(uint8_t mask){ I2C_SCL_HI(); @@ -4368,6 +4371,12 @@ clear; echo ";UA1;UD;" > /tmp/ttyS0; cat /tmp/ttyS0 | while IFS= read -d \; c; d Use pavumeter to set the correct mixer settings +For an Arduino board at 16 MHz, the following simple script will start streaming audio: + +cat /dev/ttyACM0 | aplay -c 1 -r 6249 -f U8 +stty -F /dev/ttyACM0 raw -echo -echoe -echoctl -echoke 115200; +echo ";UA1;" > /dev/ttyACM0 + */ #ifdef CAT_EXT else if((CATcmd[0] == 'U') && (CATcmd[1] == 'K') && (CATcmd[4] == ';')) // remote key press