Hi,
I am currently trying to get a BQ27441 to work properly.
The datasheet, is in my opinion pretty poor at explaining how its registers work. It refers to them as commands instead.
In any case, i have spent quite a few hours today, just trying to get it to output its own DEVICE_TYPE.
The first problem i am seeing is that when sending the device address to either read or write, i get an ACK returned.
Following on from the address i send the 2 byte "control()" command eg, 0x00, 0x01.
Both of these bytes return NACK.
I try to read the data, 2 bytes and i get something returned that is not the DEVICE_TYPE, which should be 0x0421.
So code wise this is what im doing.
START
SEND WRITE ADDRESS - GET ACK
SEND 0x00 - GET NACK
SEND 0x01 - GET NACK
STOP
WAIT 66mS
START
SEND WRITE ADDRESS - GET ACK
SEND 0x00 - GET NACK
SEND 0x01 - GET NACK
STOP
WAIT 66mS
START
SEND WRITE ADDRESS - GET ACK
SEND 0x00 - GET NACK
RESTART
SEND READ ADDRESS - GET ACK
READ MSB
READ LSB
STOP
WAIT 66mS
In return i get 0x7F, 0x7F for my read data.
Can i ask someone to take a look at the datasheet and write out how they would interpret the commands be sent, please.
BQ27441 - Incorrect data being returned
-
- Posts: 12
- http://meble-kuchenne.info.pl
- Joined: Sun Jun 20, 2021 11:55 am
- Has thanked: 2 times
- Been thanked: 1 time
-
- Matrix Staff
- Posts: 1926
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 501 times
- Been thanked: 686 times
Re: BQ27441 - Incorrect data being returned
Hello,
The datasheet does look pretty confusing. What microcontroller device are you using? If you're using a STARM or a ESP32 then there may be additional problems caused by the way the hardware I2C channel works. You can either use the software channel or use the transaction based commands.
Do you want to attach your program so far and we can have a look at at this and make sure there are no issues there.
The datasheet does look pretty confusing. What microcontroller device are you using? If you're using a STARM or a ESP32 then there may be additional problems caused by the way the hardware I2C channel works. You can either use the software channel or use the transaction based commands.
Do you want to attach your program so far and we can have a look at at this and make sure there are no issues there.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
-
- Valued Contributor
- Posts: 1454
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 135 times
- Been thanked: 708 times
Re: BQ27441 - Incorrect data being returned
One thought - the data sheet specifies a 66 microsecond delay and your listing above shows 66 milliseconds - probably just a typo in the debug output however?
Sparkfun have:
So to read device_type:
Start
Write Addr
Write 1 (Note LSB first)
Write 0
Restart
Write addr | 1
Read lsb
Read msb
Stop
See
https://github.com/sparkfun/SparkFun_BQ ... master/src
Martin
Sparkfun have:
Code: Select all
uint16_t BQ27441::readControlWord(uint16_t function)
{
uint8_t subCommandMSB = (function >> 8);
uint8_t subCommandLSB = (function & 0x00FF);
uint8_t command[2] = {subCommandLSB, subCommandMSB};
uint8_t data[2] = {0, 0};
i2cWriteBytes((uint8_t) 0, command, 2);
if (i2cReadBytes((uint8_t) 0, data, 2))
{
return ((uint16_t)data[1] << 8) | data[0];
}
return false;
}
Start
Write Addr
Write 1 (Note LSB first)
Write 0
Restart
Write addr | 1
Read lsb
Read msb
Stop
See
https://github.com/sparkfun/SparkFun_BQ ... master/src
Martin
Re: BQ27441 - Incorrect data being returned
Hi Martin,
I have tried the way you suggested. Unfortunatly it doesnt work. It returns FF, FF
Delay is a typo, sorry. I have tried it with and without the delay and theres no change.
Im sure that i am just sending the data wrong to the device. I see a few others having the same problem when i search online. I have tried to implement the solutions online, but none work. They all return different data, just not the data i expect to see.
Ben,
I am using the PIC32MX575F256L, SOFTWARE I2C. The I2C works fine as i have several other devices on the bus working fine, so far.
I have tried the way you suggested. Unfortunatly it doesnt work. It returns FF, FF
Delay is a typo, sorry. I have tried it with and without the delay and theres no change.
Im sure that i am just sending the data wrong to the device. I see a few others having the same problem when i search online. I have tried to implement the solutions online, but none work. They all return different data, just not the data i expect to see.
Ben,
I am using the PIC32MX575F256L, SOFTWARE I2C. The I2C works fine as i have several other devices on the bus working fine, so far.